src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58273 08a5148e7c4e
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
     2
 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1
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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5404
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5404
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5404
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    25
#include "precompiled.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13974
diff changeset
    26
#include "asm/macroAssembler.hpp"
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13974
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    28
#include "c1/c1_Compilation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    29
#include "c1/c1_LIRAssembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    30
#include "c1/c1_MacroAssembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    31
#include "c1/c1_Runtime1.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    32
#include "c1/c1_ValueStack.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    33
#include "ci/ciArrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    34
#include "ci/ciInstance.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29456
diff changeset
    35
#include "gc/shared/barrierSet.hpp"
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49449
diff changeset
    36
#include "gc/shared/cardTableBarrierSet.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29456
diff changeset
    37
#include "gc/shared/collectedHeap.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    38
#include "nativeInst_x86.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    39
#include "oops/objArrayKlass.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49470
diff changeset
    40
#include "runtime/frame.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49027
diff changeset
    41
#include "runtime/safepointMechanism.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6774
diff changeset
    42
#include "runtime/sharedRuntime.hpp"
22502
f8adbdb312a1 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 21102
diff changeset
    43
#include "vmreg_x86.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// These masks are used to provide 128-bit aligned bitmasks to the XMM
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// instructions, to allow sign-masking or sign-bit flipping.  They allow
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// fast versions of NegF/NegD and AbsF/AbsD.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// Note: 'double' and 'long long' have 32-bits alignment on x86.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
static jlong* double_quadword(jlong *adr, jlong lo, jlong hi) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // Use the expression (adr)&(~0xF) to provide 128-bits aligned address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // of 128-bits operands for SSE instructions.
9958
dedfe67ddc58 7046893: LP64 problem with double_quadword in c1_LIRAssembler_x86.cpp
iveresov
parents: 9135
diff changeset
    54
  jlong *operand = (jlong*)(((intptr_t)adr) & ((intptr_t)(~0xF)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Store the value to a 128-bits operand.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  operand[0] = lo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  operand[1] = hi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  return operand;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// Buffer for 128-bits masks used by SSE instructions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
static jlong fp_signmask_pool[(4+1)*2]; // 4*128bits(data) + 128bits(alignment)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// Static initialization during VM startup.
27471
6e56277909f1 8062370: Various minor code improvements
goetz
parents: 25067
diff changeset
    65
static jlong *float_signmask_pool  = double_quadword(&fp_signmask_pool[1*2],         CONST64(0x7FFFFFFF7FFFFFFF),         CONST64(0x7FFFFFFF7FFFFFFF));
6e56277909f1 8062370: Various minor code improvements
goetz
parents: 25067
diff changeset
    66
static jlong *double_signmask_pool = double_quadword(&fp_signmask_pool[2*2],         CONST64(0x7FFFFFFFFFFFFFFF),         CONST64(0x7FFFFFFFFFFFFFFF));
6e56277909f1 8062370: Various minor code improvements
goetz
parents: 25067
diff changeset
    67
static jlong *float_signflip_pool  = double_quadword(&fp_signmask_pool[3*2], (jlong)UCONST64(0x8000000080000000), (jlong)UCONST64(0x8000000080000000));
6e56277909f1 8062370: Various minor code improvements
goetz
parents: 25067
diff changeset
    68
static jlong *double_signflip_pool = double_quadword(&fp_signmask_pool[4*2], (jlong)UCONST64(0x8000000000000000), (jlong)UCONST64(0x8000000000000000));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
NEEDS_CLEANUP // remove this definitions ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
const Register IC_Klass    = rax;   // where the IC klass is cached
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
const Register SYNC_header = rax;   // synchronization header
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
const Register SHIFT_count = rcx;   // where count for shift operations must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
static void select_different_registers(Register preserve,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
                                       Register extra,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
                                       Register &tmp1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
                                       Register &tmp2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  if (tmp1 == preserve) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    assert_different_registers(tmp1, tmp2, extra);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    tmp1 = extra;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  } else if (tmp2 == preserve) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    assert_different_registers(tmp1, tmp2, extra);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    tmp2 = extra;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  assert_different_registers(preserve, tmp1, tmp2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
static void select_different_registers(Register preserve,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
                                       Register extra,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
                                       Register &tmp1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                                       Register &tmp2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
                                       Register &tmp3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  if (tmp1 == preserve) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    assert_different_registers(tmp1, tmp2, tmp3, extra);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    tmp1 = extra;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  } else if (tmp2 == preserve) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    assert_different_registers(tmp1, tmp2, tmp3, extra);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    tmp2 = extra;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  } else if (tmp3 == preserve) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    assert_different_registers(tmp1, tmp2, tmp3, extra);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    tmp3 = extra;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  assert_different_registers(preserve, tmp1, tmp2, tmp3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
bool LIR_Assembler::is_small_constant(LIR_Opr opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  if (opr->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    LIR_Const* constant = opr->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    switch (constant->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      case T_INT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
        return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
LIR_Opr LIR_Assembler::receiverOpr() {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   132
  return FrameMap::receiver_opr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
LIR_Opr LIR_Assembler::osrBufferPointer() {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   136
  return FrameMap::as_pointer_opr(receiverOpr()->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
//--------------fpu register translations-----------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
address LIR_Assembler::float_constant(float f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  address const_addr = __ float_constant(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  if (const_addr == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    bailout("const section overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    return __ code()->consts()->start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    return const_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
address LIR_Assembler::double_constant(double d) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  address const_addr = __ double_constant(d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  if (const_addr == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    bailout("const section overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    return __ code()->consts()->start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    return const_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
void LIR_Assembler::set_24bit_FPU() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
void LIR_Assembler::reset_FPU() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
void LIR_Assembler::fpop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  __ fpop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
void LIR_Assembler::fxch(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  __ fxch(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
void LIR_Assembler::fld(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  __ fld_s(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
void LIR_Assembler::ffree(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  __ ffree(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
void LIR_Assembler::breakpoint() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  __ int3();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
void LIR_Assembler::push(LIR_Opr opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  if (opr->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    __ push_reg(opr->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  } else if (opr->is_double_cpu()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   196
    NOT_LP64(__ push_reg(opr->as_register_hi()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    __ push_reg(opr->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  } else if (opr->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    __ push_addr(frame_map()->address_for_slot(opr->single_stack_ix()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  } else if (opr->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    LIR_Const* const_opr = opr->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    if (const_opr->type() == T_OBJECT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      __ push_oop(const_opr->as_jobject());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    } else if (const_opr->type() == T_INT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
      __ push_jint(const_opr->as_jint());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
void LIR_Assembler::pop(LIR_Opr opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  if (opr->is_single_cpu()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   217
    __ pop_reg(opr->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   223
bool LIR_Assembler::is_literal_address(LIR_Address* addr) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   224
  return addr->base()->is_illegal() && addr->index()->is_illegal();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   225
}
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   226
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
//-------------------------------------------
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   228
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
Address LIR_Assembler::as_Address(LIR_Address* addr) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   230
  return as_Address(addr, rscratch1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   231
}
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   232
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   233
Address LIR_Assembler::as_Address(LIR_Address* addr, Register tmp) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  if (addr->base()->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    assert(addr->index()->is_illegal(), "must be illegal too");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   236
    AddressLiteral laddr((address)addr->disp(), relocInfo::none);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   237
    if (! __ reachable(laddr)) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   238
      __ movptr(tmp, laddr.addr());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   239
      Address res(tmp, 0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   240
      return res;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   241
    } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   242
      return __ as_Address(laddr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   243
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   246
  Register base = addr->base()->as_pointer_register();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  if (addr->index()->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    return Address( base, addr->disp());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   250
  } else if (addr->index()->is_cpu_register()) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   251
    Register index = addr->index()->as_pointer_register();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    return Address(base, index, (Address::ScaleFactor) addr->scale(), addr->disp());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  } else if (addr->index()->is_constant()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   254
    intptr_t addr_offset = (addr->index()->as_constant_ptr()->as_jint() << addr->scale()) + addr->disp();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   255
    assert(Assembler::is_simm32(addr_offset), "must be");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    return Address(base, addr_offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    return Address();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
Address LIR_Assembler::as_Address_hi(LIR_Address* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  Address base = as_Address(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  return Address(base._base, base._index, base._scale, base._disp + BytesPerWord);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
Address LIR_Assembler::as_Address_lo(LIR_Address* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  return as_Address(addr);
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
void LIR_Assembler::osr_entry() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  offsets()->set_value(CodeOffsets::OSR_Entry, code_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  BlockBegin* osr_entry = compilation()->hir()->osr_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  ValueStack* entry_state = osr_entry->state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  int number_of_locks = entry_state->locks_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // we jump here if osr happens with the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  // state set up to continue at the beginning of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  // loop that triggered osr - in particular, we have
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  // the following registers setup:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // rcx: osr buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // build frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  ciMethod* m = compilation()->method();
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23530
diff changeset
   292
  __ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // OSR buffer is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // locals[nlocals-1..0]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  // monitors[0..number_of_locks]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // locals is a direct copy of the interpreter frame so in the osr buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  // so first slot in the local array is the last local from the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  // and last slot is local[0] (receiver) from the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  // Similarly with locks. The first lock slot in the osr buffer is the nth lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  // from the interpreter frame, the nth lock slot in the osr buffer is 0th lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  // in the interpreter frame (the method lock if a sync method)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  // Initialize monitors in the compiled activation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  //   rcx: pointer to osr buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  // All other registers are dead at this point and the locals will be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // copied into place by code emitted in the IR.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   313
  Register OSR_buf = osrBufferPointer()->as_pointer_register();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    int monitor_offset = BytesPerWord * method()->max_locals() +
37251
9fc139ad74b5 8152358: code and comment cleanups found during the hunt for 8077392
dcubed
parents: 35540
diff changeset
   316
      (BasicObjectLock::size() * BytesPerWord) * (number_of_locks - 1);
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   317
    // SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   318
    // the OSR buffer using 2 word entries: first the lock and then
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   319
    // the oop.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    for (int i = 0; i < number_of_locks; i++) {
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   321
      int slot_offset = monitor_offset - ((i * 2) * BytesPerWord);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
      // verify the interpreter's monitor has a non-null object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
        Label L;
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   326
        __ cmpptr(Address(OSR_buf, slot_offset + 1*BytesPerWord), (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
        __ jcc(Assembler::notZero, L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
        __ stop("locked object is NULL");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
        __ bind(L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
#endif
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   332
      __ movptr(rbx, Address(OSR_buf, slot_offset + 0));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   333
      __ movptr(frame_map()->address_for_monitor_lock(i), rbx);
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   334
      __ movptr(rbx, Address(OSR_buf, slot_offset + 1*BytesPerWord));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   335
      __ movptr(frame_map()->address_for_monitor_object(i), rbx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
// inline cache check; done before the frame is built.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
int LIR_Assembler::check_icache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  Register receiver = FrameMap::receiver_opr->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  Register ic_klass = IC_Klass;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   345
  const int ic_cmp_size = LP64_ONLY(10) NOT_LP64(9);
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
   346
  const bool do_post_padding = VerifyOops || UseCompressedClassPointers;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   347
  if (!do_post_padding) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    // insert some nops so that the verified entry point is aligned on CodeEntryAlignment
32203
01a3716ed455 8131682: C1 should use multibyte nops everywhere
shade
parents: 30764
diff changeset
   349
    __ align(CodeEntryAlignment, __ offset() + ic_cmp_size);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  int offset = __ offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  __ inline_cache_check(receiver, IC_Klass);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   353
  assert(__ offset() % CodeEntryAlignment == 0 || do_post_padding, "alignment must be correct");
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   354
  if (do_post_padding) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    // force alignment after the cache check.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    // It's been verified to be aligned if !VerifyOops
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    __ align(CodeEntryAlignment);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  return offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
55105
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   362
void LIR_Assembler::clinit_barrier(ciMethod* method) {
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   363
  assert(VM_Version::supports_fast_class_init_checks(), "sanity");
55253
3c905e67e380 8225106: C2: Parse::clinit_deopt asserts when holder klass is in error state
vlivanov
parents: 55105
diff changeset
   364
  assert(!method->holder()->is_not_initialized(), "initialization should have been started");
55105
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   365
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   366
  Label L_skip_barrier;
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   367
  Register klass = rscratch1;
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   368
  Register thread = LP64_ONLY( r15_thread ) NOT_LP64( noreg );
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   369
  assert(thread != noreg, "x86_32 not implemented");
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   370
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   371
  __ mov_metadata(klass, method->holder()->constant_encoding());
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   372
  __ clinit_barrier(klass, thread, &L_skip_barrier /*L_fast_path*/);
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   373
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   374
  __ jump(RuntimeAddress(SharedRuntime::get_handle_wrong_method_stub()));
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   375
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   376
  __ bind(L_skip_barrier);
9ad765641e8f 8223213: Implement fast class initialization checks on x86-64
vlivanov
parents: 53171
diff changeset
   377
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  jobject o = NULL;
19710
2f8ca425504e 7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
roland
parents: 18507
diff changeset
   381
  PatchingStub* patch = new PatchingStub(_masm, patching_id(info));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  __ movoop(reg, o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  patching_epilog(patch, lir_patch_normal, reg, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   386
void LIR_Assembler::klass2reg_with_patching(Register reg, CodeEmitInfo* info) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   387
  Metadata* o = NULL;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   388
  PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_klass_id);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   389
  __ mov_metadata(reg, o);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   390
  patching_epilog(patch, lir_patch_normal, reg, info);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   391
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
// This specifies the rsp decrement needed to build the frame
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 23530
diff changeset
   394
int LIR_Assembler::initial_frame_size_in_bytes() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  // if rounding, must let FrameMap know!
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   396
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   397
  // The frame_map records size in slots (32bit word)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   398
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   399
  // subtract two words to account for return address and link
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   400
  return (frame_map()->framesize() - (2*VMRegImpl::slots_per_word))  * VMRegImpl::stack_slot_size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   404
int LIR_Assembler::emit_exception_handler() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  // if the last instruction is a call (typically to do a throw which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  // is coming at the end after block reordering) the return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  // must still point into the code area in order to avoid assertion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  // failures when searching for the corresponding bci => add a nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  // (was bug 5/14/1999 - gri)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  __ nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  // generate code for exception handler
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
   413
  address handler_base = __ start_a_stub(exception_handler_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  if (handler_base == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    // not enough space left for the handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    bailout("exception handler overflow");
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   417
    return -1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  }
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   419
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  int offset = code_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   422
  // the exception oop and pc are in rax, and rdx
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  // no other registers need to be preserved, so invalidate them
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   424
  __ invalidate_registers(false, true, true, false, true, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  // check that there is really an exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  __ verify_not_null_oop(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   429
  // search an exception handler (rax: exception oop, rdx: throwing pc)
8495
a4959965eaa3 7012914: JSR 292 MethodHandlesTest C1: frame::verify_return_pc(return_address) failed: must be a return pc
twisti
parents: 7883
diff changeset
   430
  __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_from_callee_id)));
a4959965eaa3 7012914: JSR 292 MethodHandlesTest C1: frame::verify_return_pc(return_address) failed: must be a return pc
twisti
parents: 7883
diff changeset
   431
  __ should_not_reach_here();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
   432
  guarantee(code_offset() - offset <= exception_handler_size(), "overflow");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  __ end_a_stub();
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   434
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   435
  return offset;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   438
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   439
// Emit the code to remove the frame from the stack in the exception
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   440
// unwind path.
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   441
int LIR_Assembler::emit_unwind_handler() {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   442
#ifndef PRODUCT
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   443
  if (CommentedAssembly) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   444
    _masm->block_comment("Unwind handler");
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   445
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   446
#endif
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   447
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   448
  int offset = code_offset();
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   449
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   450
  // Fetch the exception from TLS and clear out exception related thread state
21102
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   451
  Register thread = NOT_LP64(rsi) LP64_ONLY(r15_thread);
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   452
  NOT_LP64(__ get_thread(rsi));
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   453
  __ movptr(rax, Address(thread, JavaThread::exception_oop_offset()));
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   454
  __ movptr(Address(thread, JavaThread::exception_oop_offset()), (intptr_t)NULL_WORD);
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   455
  __ movptr(Address(thread, JavaThread::exception_pc_offset()), (intptr_t)NULL_WORD);
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   456
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   457
  __ bind(_unwind_handler_entry);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   458
  __ verify_not_null_oop(rax);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   459
  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
21102
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   460
    __ mov(rbx, rax);  // Preserve the exception (rbx is always callee-saved)
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   461
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   462
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   463
  // Preform needed unlocking
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   464
  MonitorExitStub* stub = NULL;
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   465
  if (method()->is_synchronized()) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   466
    monitor_address(0, FrameMap::rax_opr);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   467
    stub = new MonitorExitStub(FrameMap::rax_opr, true, 0);
21102
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   468
    __ unlock_object(rdi, rsi, rax, *stub->entry());
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   469
    __ bind(*stub->continuation());
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   470
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   471
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   472
  if (compilation()->env()->dtrace_method_probes()) {
21102
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   473
#ifdef _LP64
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   474
    __ mov(rdi, r15_thread);
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   475
    __ mov_metadata(rsi, method()->constant_encoding());
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   476
#else
6756
01ac7b1701eb 6988018: dtrace/hotspot/MethodInvocation/MethodInvocation002 crashes with client compiler
never
parents: 6461
diff changeset
   477
    __ get_thread(rax);
01ac7b1701eb 6988018: dtrace/hotspot/MethodInvocation/MethodInvocation002 crashes with client compiler
never
parents: 6461
diff changeset
   478
    __ movptr(Address(rsp, 0), rax);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   479
    __ mov_metadata(Address(rsp, sizeof(void*)), method()->constant_encoding());
21102
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   480
#endif
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   481
    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit)));
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   482
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   483
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   484
  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
21102
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21088
diff changeset
   485
    __ mov(rax, rbx);  // Restore the exception
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   486
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   487
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   488
  // remove the activation and dispatch to the unwind handler
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   489
  __ remove_frame(initial_frame_size_in_bytes());
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   490
  __ jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id)));
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   491
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   492
  // Emit the slow path assembly
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   493
  if (stub != NULL) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   494
    stub->emit_code(this);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   495
  }
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   496
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   497
  return offset;
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   498
}
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   499
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
   500
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   501
int LIR_Assembler::emit_deopt_handler() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  // if the last instruction is a call (typically to do a throw which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  // is coming at the end after block reordering) the return address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  // must still point into the code area in order to avoid assertion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  // failures when searching for the corresponding bci => add a nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  // (was bug 5/14/1999 - gri)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  __ nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  // generate code for exception handler
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
   510
  address handler_base = __ start_a_stub(deopt_handler_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  if (handler_base == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    // not enough space left for the handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    bailout("deopt handler overflow");
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   514
    return -1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  }
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   516
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  int offset = code_offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  InternalAddress here(__ pc());
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   519
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  __ pushptr(here.addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  __ jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack()));
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
   522
  guarantee(code_offset() - offset <= deopt_handler_size(), "overflow");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  __ end_a_stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   525
  return offset;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
void LIR_Assembler::return_op(LIR_Opr result) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  assert(result->is_illegal() || !result->is_single_cpu() || result->as_register() == rax, "word returns are in rax,");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  if (!result->is_illegal() && result->is_float_kind() && !result->is_xmm_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    assert(result->fpu() == 0, "result must already be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  // Pop the stack before the safepoint code
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
   536
  __ remove_frame(initial_frame_size_in_bytes());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
35071
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34200
diff changeset
   538
  if (StackReservedPages > 0 && compilation()->has_reserved_stack_access()) {
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34200
diff changeset
   539
    __ reserved_stack_check();
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34200
diff changeset
   540
  }
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34200
diff changeset
   541
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  bool result_is_oop = result->is_valid() ? result->is_oop() : false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  // Note: we do not need to round double result; float result has the right precision
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  // the poll sets the condition code, but no data registers
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   546
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   547
  if (SafepointMechanism::uses_thread_local_poll()) {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   548
#ifdef _LP64
49027
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   549
    const Register poll_addr = rscratch1;
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   550
    __ movptr(poll_addr, Address(r15_thread, Thread::polling_page_offset()));
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   551
#else
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   552
    const Register poll_addr = rbx;
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   553
    assert(FrameMap::is_caller_save_register(poll_addr), "will overwrite");
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   554
    __ get_thread(poll_addr);
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   555
    __ movptr(poll_addr, Address(poll_addr, Thread::polling_page_offset()));
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   556
#endif
8871
5c3b26c4119e 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 8495
diff changeset
   557
    __ relocate(relocInfo::poll_return_type);
49027
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   558
    __ testl(rax, Address(poll_addr, 0));
8871
5c3b26c4119e 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 8495
diff changeset
   559
  } else {
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   560
    AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   561
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   562
    if (Assembler::is_polling_page_far()) {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   563
      __ lea(rscratch1, polling_page);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   564
      __ relocate(relocInfo::poll_return_type);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   565
      __ testl(rax, Address(rscratch1, 0));
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   566
    } else {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   567
      __ testl(rax, polling_page);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   568
    }
8871
5c3b26c4119e 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 8495
diff changeset
   569
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
8871
5c3b26c4119e 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 8495
diff changeset
   575
  guarantee(info != NULL, "Shouldn't be NULL");
5c3b26c4119e 6964776: c2 should ensure the polling page is reachable on 64 bit
iveresov
parents: 8495
diff changeset
   576
  int offset = __ offset();
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   577
  if (SafepointMechanism::uses_thread_local_poll()) {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   578
#ifdef _LP64
49027
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   579
    const Register poll_addr = rscratch1;
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   580
    __ movptr(poll_addr, Address(r15_thread, Thread::polling_page_offset()));
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   581
#else
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   582
    assert(tmp->is_cpu_register(), "needed");
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   583
    const Register poll_addr = tmp->as_register();
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   584
    __ get_thread(poll_addr);
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   585
    __ movptr(poll_addr, Address(poll_addr, in_bytes(Thread::polling_page_offset())));
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   586
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    add_debug_info_for_branch(info);
25067
3b9a0ebd9a27 8046684: sharedRuntime.cpp...assert(((nmethod*)cb)->is_at_poll_or_poll_return(pc)) failed: safepoint polling: type must be poll
iveresov
parents: 24018
diff changeset
   588
    __ relocate(relocInfo::poll_type);
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   589
    address pre_pc = __ pc();
49027
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   590
    __ testl(rax, Address(poll_addr, 0));
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   591
    address post_pc = __ pc();
49027
8dc742d9bbab 8195112: x86 (32 bit): implementation for Thread-local handshakes
mdoerr
parents: 48856
diff changeset
   592
    guarantee(pointer_delta(post_pc, pre_pc, 1) == 2 LP64_ONLY(+1), "must be exact length");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  } else {
47881
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   594
    AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_type);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   595
    if (Assembler::is_polling_page_far()) {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   596
      __ lea(rscratch1, polling_page);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   597
      offset = __ offset();
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   598
      add_debug_info_for_branch(info);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   599
      __ relocate(relocInfo::poll_type);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   600
      __ testl(rax, Address(rscratch1, 0));
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   601
    } else {
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   602
      add_debug_info_for_branch(info);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   603
      __ testl(rax, polling_page);
0ce0ac68ace7 8189941: Implementation JEP 312: Thread-local handshake
rehn
parents: 47698
diff changeset
   604
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  return offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
void LIR_Assembler::move_regs(Register from_reg, Register to_reg) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   611
  if (from_reg != to_reg) __ mov(to_reg, from_reg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
void LIR_Assembler::swap_reg(Register a, Register b) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   615
  __ xchgptr(a, b);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  assert(src->is_constant(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  assert(dest->is_register(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  LIR_Const* c = src->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  switch (c->type()) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   625
    case T_INT: {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   626
      assert(patch_code == lir_patch_none, "no patching handled here");
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   627
      __ movl(dest->as_register(), c->as_jint());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   628
      break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   629
    }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   630
5048
c31b6243f37e 6932496: c1: deoptimization of jsr subroutine fails on sparcv9
roland
parents: 5046
diff changeset
   631
    case T_ADDRESS: {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
      assert(patch_code == lir_patch_none, "no patching handled here");
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   633
      __ movptr(dest->as_register(), c->as_jint());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
    case T_LONG: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
      assert(patch_code == lir_patch_none, "no patching handled here");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   639
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   640
      __ movptr(dest->as_register_lo(), (intptr_t)c->as_jlong());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   641
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   642
      __ movptr(dest->as_register_lo(), c->as_jint_lo());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   643
      __ movptr(dest->as_register_hi(), c->as_jint_hi());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   644
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
    case T_OBJECT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
      if (patch_code != lir_patch_none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
        jobject2reg_with_patching(dest->as_register(), info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
        __ movoop(dest->as_register(), c->as_jobject());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   657
    case T_METADATA: {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   658
      if (patch_code != lir_patch_none) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   659
        klass2reg_with_patching(dest->as_register(), info);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   660
      } else {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   661
        __ mov_metadata(dest->as_register(), c->as_metadata());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   662
      }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   663
      break;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   664
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   665
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    case T_FLOAT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
      if (dest->is_single_xmm()) {
53171
3ab3cb8a8d41 8215888: Register to register spill may use AVX 512 move instruction on unsupported platform.
sviswanathan
parents: 52675
diff changeset
   668
        if (LP64_ONLY(UseAVX <= 2 &&) c->is_zero_float()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
          __ xorps(dest->as_xmm_float_reg(), dest->as_xmm_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
          __ movflt(dest->as_xmm_float_reg(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
                   InternalAddress(float_constant(c->as_jfloat())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
        assert(dest->is_single_fpu(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
        assert(dest->fpu_regnr() == 0, "dest must be TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
        if (c->is_zero_float()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
          __ fldz();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
        } else if (c->is_one_float()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
          __ fld1();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
          __ fld_s (InternalAddress(float_constant(c->as_jfloat())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
    case T_DOUBLE: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
      if (dest->is_double_xmm()) {
53171
3ab3cb8a8d41 8215888: Register to register spill may use AVX 512 move instruction on unsupported platform.
sviswanathan
parents: 52675
diff changeset
   690
        if (LP64_ONLY(UseAVX <= 2 &&) c->is_zero_double()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
          __ xorpd(dest->as_xmm_double_reg(), dest->as_xmm_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
          __ movdbl(dest->as_xmm_double_reg(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
                    InternalAddress(double_constant(c->as_jdouble())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
        assert(dest->is_double_fpu(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
        assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
        if (c->is_zero_double()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
          __ fldz();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
        } else if (c->is_one_double()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
          __ fld1();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
          __ fld_d (InternalAddress(double_constant(c->as_jdouble())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  assert(src->is_constant(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  assert(dest->is_stack(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  LIR_Const* c = src->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  switch (c->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
    case T_INT:  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
    case T_FLOAT:
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   723
      __ movl(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jint_bits());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   724
      break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   725
5048
c31b6243f37e 6932496: c1: deoptimization of jsr subroutine fails on sparcv9
roland
parents: 5046
diff changeset
   726
    case T_ADDRESS:
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   727
      __ movptr(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jint_bits());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
    case T_OBJECT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
      __ movoop(frame_map()->address_for_slot(dest->single_stack_ix()), c->as_jobject());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
    case T_LONG:  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
    case T_DOUBLE:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   736
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   737
      __ movptr(frame_map()->address_for_slot(dest->double_stack_ix(),
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   738
                                            lo_word_offset_in_bytes), (intptr_t)c->as_jlong_bits());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   739
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   740
      __ movptr(frame_map()->address_for_slot(dest->double_stack_ix(),
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   741
                                              lo_word_offset_in_bytes), c->as_jint_lo_bits());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   742
      __ movptr(frame_map()->address_for_slot(dest->double_stack_ix(),
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   743
                                              hi_word_offset_in_bytes), c->as_jint_hi_bits());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   744
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   752
void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info, bool wide) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  assert(src->is_constant(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
  assert(dest->is_address(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
  LIR_Const* c = src->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
  LIR_Address* addr = dest->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   758
  int null_check_here = code_offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
    case T_INT:    // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
    case T_FLOAT:
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   762
      __ movl(as_Address(addr), c->as_jint_bits());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   763
      break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   764
5048
c31b6243f37e 6932496: c1: deoptimization of jsr subroutine fails on sparcv9
roland
parents: 5046
diff changeset
   765
    case T_ADDRESS:
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   766
      __ movptr(as_Address(addr), c->as_jint_bits());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
    case T_OBJECT:  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
    case T_ARRAY:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
      if (c->as_jobject() == NULL) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   772
        if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   773
          __ movl(as_Address(addr), (int32_t)NULL_WORD);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   774
        } else {
23530
b0fb0c2df62b 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 23490
diff changeset
   775
#ifdef _LP64
b0fb0c2df62b 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 23490
diff changeset
   776
          __ xorptr(rscratch1, rscratch1);
b0fb0c2df62b 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 23490
diff changeset
   777
          null_check_here = code_offset();
b0fb0c2df62b 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 23490
diff changeset
   778
          __ movptr(as_Address(addr), rscratch1);
b0fb0c2df62b 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 23490
diff changeset
   779
#else
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   780
          __ movptr(as_Address(addr), NULL_WORD);
23530
b0fb0c2df62b 8039043: Implicit null check is in the wrong place in C1 -UseCompressedOops
iveresov
parents: 23490
diff changeset
   781
#endif
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   782
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
      } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   784
        if (is_literal_address(addr)) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   785
          ShouldNotReachHere();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   786
          __ movoop(as_Address(addr, noreg), c->as_jobject());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   787
        } else {
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   788
#ifdef _LP64
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   789
          __ movoop(rscratch1, c->as_jobject());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   790
          if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   791
            __ encode_heap_oop(rscratch1);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   792
            null_check_here = code_offset();
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   793
            __ movl(as_Address_lo(addr), rscratch1);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   794
          } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   795
            null_check_here = code_offset();
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   796
            __ movptr(as_Address_lo(addr), rscratch1);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   797
          }
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   798
#else
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   799
          __ movoop(as_Address(addr), c->as_jobject());
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
   800
#endif
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   801
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
    case T_LONG:    // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
    case T_DOUBLE:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   807
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   808
      if (is_literal_address(addr)) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   809
        ShouldNotReachHere();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   810
        __ movptr(as_Address(addr, r15_thread), (intptr_t)c->as_jlong_bits());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   811
      } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   812
        __ movptr(r10, (intptr_t)c->as_jlong_bits());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   813
        null_check_here = code_offset();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   814
        __ movptr(as_Address_lo(addr), r10);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   815
      }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   816
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   817
      // Always reachable in 32bit so this doesn't produce useless move literal
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   818
      __ movptr(as_Address_hi(addr), c->as_jint_hi_bits());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   819
      __ movptr(as_Address_lo(addr), c->as_jint_lo_bits());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   820
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
    case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
    case T_BYTE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
      __ movb(as_Address(addr), c->as_jint() & 0xFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
    case T_CHAR:    // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
    case T_SHORT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
      __ movw(as_Address(addr), c->as_jint() & 0xFFFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
  };
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   836
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   837
  if (info != NULL) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   838
    add_debug_info_for_null_check(null_check_here, info);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   839
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
void LIR_Assembler::reg2reg(LIR_Opr src, LIR_Opr dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  assert(src->is_register(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  assert(dest->is_register(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  // move between cpu-registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
  if (dest->is_single_cpu()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   849
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   850
    if (src->type() == T_LONG) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   851
      // Can do LONG -> OBJECT
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   852
      move_regs(src->as_register_lo(), dest->as_register());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   853
      return;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   854
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   855
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
    assert(src->is_single_cpu(), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
    if (src->type() == T_OBJECT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
      __ verify_oop(src->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
    move_regs(src->as_register(), dest->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
  } else if (dest->is_double_cpu()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   863
#ifdef _LP64
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
   864
    if (is_reference_type(src->type())) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   865
      // Surprising to me but we can see move of a long to t_object
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   866
      __ verify_oop(src->as_register());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   867
      move_regs(src->as_register(), dest->as_register_lo());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   868
      return;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   869
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   870
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
    assert(src->is_double_cpu(), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
    Register f_lo = src->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
    Register f_hi = src->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
    Register t_lo = dest->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
    Register t_hi = dest->as_register_hi();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   876
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   877
    assert(f_hi == f_lo, "must be same");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   878
    assert(t_hi == t_lo, "must be same");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   879
    move_regs(f_lo, t_lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   880
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
    assert(f_lo != f_hi && t_lo != t_hi, "invalid register allocation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   883
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
    if (f_lo == t_hi && f_hi == t_lo) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
      swap_reg(f_lo, f_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
    } else if (f_hi == t_lo) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
      assert(f_lo != t_hi, "overwriting register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
      move_regs(f_hi, t_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
      move_regs(f_lo, t_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
      assert(f_hi != t_lo, "overwriting register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
      move_regs(f_lo, t_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
      move_regs(f_hi, t_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
    }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   895
#endif // LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
    // special moves from fpu-register to xmm-register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
    // necessary for method results
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  } else if (src->is_single_xmm() && !dest->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
    __ movflt(Address(rsp, 0), src->as_xmm_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
    __ fld_s(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
  } else if (src->is_double_xmm() && !dest->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
    __ movdbl(Address(rsp, 0), src->as_xmm_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
    __ fld_d(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
  } else if (dest->is_single_xmm() && !src->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
    __ fstp_s(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
    __ movflt(dest->as_xmm_float_reg(), Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
  } else if (dest->is_double_xmm() && !src->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
    __ fstp_d(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
    __ movdbl(dest->as_xmm_double_reg(), Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
    // move between xmm-registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
  } else if (dest->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
    assert(src->is_single_xmm(), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
    __ movflt(dest->as_xmm_float_reg(), src->as_xmm_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
  } else if (dest->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
    assert(src->is_double_xmm(), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
    __ movdbl(dest->as_xmm_double_reg(), src->as_xmm_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
    // move between fpu-registers (no instruction necessary because of fpu-stack)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
  } else if (dest->is_single_fpu() || dest->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
    assert(src->is_single_fpu() || src->is_double_fpu(), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
    assert(src->fpu() == dest->fpu(), "currently should be nothing to do");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
void LIR_Assembler::reg2stack(LIR_Opr src, LIR_Opr dest, BasicType type, bool pop_fpu_stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  assert(src->is_register(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
  assert(dest->is_stack(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
  if (src->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
    Address dst = frame_map()->address_for_slot(dest->single_stack_ix());
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
   935
    if (is_reference_type(type)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
      __ verify_oop(src->as_register());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   937
      __ movptr (dst, src->as_register());
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
   938
    } else if (type == T_METADATA) {
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
   939
      __ movptr (dst, src->as_register());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   940
    } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   941
      __ movl (dst, src->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
  } else if (src->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
    Address dstLO = frame_map()->address_for_slot(dest->double_stack_ix(), lo_word_offset_in_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
    Address dstHI = frame_map()->address_for_slot(dest->double_stack_ix(), hi_word_offset_in_bytes);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   947
    __ movptr (dstLO, src->as_register_lo());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   948
    NOT_LP64(__ movptr (dstHI, src->as_register_hi()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  } else if (src->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
    __ movflt(dst_addr, src->as_xmm_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
  } else if (src->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
    Address dst_addr = frame_map()->address_for_slot(dest->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
    __ movdbl(dst_addr, src->as_xmm_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  } else if (src->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
    assert(src->fpu_regnr() == 0, "argument must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
    Address dst_addr = frame_map()->address_for_slot(dest->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
    if (pop_fpu_stack)     __ fstp_s (dst_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
    else                   __ fst_s  (dst_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
  } else if (src->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
    assert(src->fpu_regnrLo() == 0, "argument must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
    Address dst_addr = frame_map()->address_for_slot(dest->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
    if (pop_fpu_stack)     __ fstp_d (dst_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
    else                   __ fst_d  (dst_addr);
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
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   976
void LIR_Assembler::reg2mem(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool wide, bool /* unaligned */) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
  LIR_Address* to_addr = dest->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
  PatchingStub* patch = NULL;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   979
  Register compressed_src = rscratch1;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
   981
  if (is_reference_type(type)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
    __ verify_oop(src->as_register());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   983
#ifdef _LP64
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   984
    if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   985
      __ movptr(compressed_src, src->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   986
      __ encode_heap_oop(compressed_src);
22502
f8adbdb312a1 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 21102
diff changeset
   987
      if (patch_code != lir_patch_none) {
f8adbdb312a1 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 21102
diff changeset
   988
        info->oop_map()->set_narrowoop(compressed_src->as_VMReg());
f8adbdb312a1 8028764: dtrace/hotspot_jni/ALL/ALL001 crashes the vm on Solaris-amd64, SIGSEGV in MarkSweep::follow_stack()+0x8a
roland
parents: 21102
diff changeset
   989
      }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   990
    }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   991
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
  }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   993
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
  if (patch_code != lir_patch_none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
    patch = new PatchingStub(_masm, PatchingStub::access_field_id);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   996
    Address toa = as_Address(to_addr);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
   997
    assert(toa.disp() != 0, "must have");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
  }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   999
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1000
  int null_check_here = code_offset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
    case T_FLOAT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
      if (src->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
        __ movflt(as_Address(to_addr), src->as_xmm_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
        assert(src->is_single_fpu(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
        assert(src->fpu_regnr() == 0, "argument must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
        if (pop_fpu_stack)      __ fstp_s(as_Address(to_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
        else                    __ fst_s (as_Address(to_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
    case T_DOUBLE: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
      if (src->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
        __ movdbl(as_Address(to_addr), src->as_xmm_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
        assert(src->is_double_fpu(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
        assert(src->fpu_regnrLo() == 0, "argument must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
        if (pop_fpu_stack)      __ fstp_d(as_Address(to_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
        else                    __ fst_d (as_Address(to_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
    case T_ARRAY:   // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
    case T_OBJECT:  // fall through
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1028
      if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1029
        __ movl(as_Address(to_addr), compressed_src);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1030
      } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1031
        __ movptr(as_Address(to_addr), src->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1032
      }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1033
      break;
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1034
    case T_METADATA:
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1035
      // We get here to store a method pointer to the stack to pass to
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1036
      // a dtrace runtime call. This can't work on 64 bit with
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1037
      // compressed klass ptrs: T_METADATA can be a compressed klass
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1038
      // ptr or a 64 bit method pointer.
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1039
      LP64_ONLY(ShouldNotReachHere());
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1040
      __ movptr(as_Address(to_addr), src->as_register());
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1041
      break;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1042
    case T_ADDRESS:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1043
      __ movptr(as_Address(to_addr), src->as_register());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1044
      break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
    case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
      __ movl(as_Address(to_addr), src->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
    case T_LONG: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
      Register from_lo = src->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
      Register from_hi = src->as_register_hi();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1052
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1053
      __ movptr(as_Address_lo(to_addr), from_lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1054
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
      Register base = to_addr->base()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
      Register index = noreg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
      if (to_addr->index()->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
        index = to_addr->index()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
      if (base == from_lo || index == from_lo) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
        assert(base != from_hi, "can't be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
        assert(index == noreg || (index != base && index != from_hi), "can't handle this");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
        __ movl(as_Address_hi(to_addr), from_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
        if (patch != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
          patching_epilog(patch, lir_patch_high, base, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
          patch = new PatchingStub(_masm, PatchingStub::access_field_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
          patch_code = lir_patch_low;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
        __ movl(as_Address_lo(to_addr), from_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
        assert(index == noreg || (index != base && index != from_lo), "can't handle this");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
        __ movl(as_Address_lo(to_addr), from_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
        if (patch != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
          patching_epilog(patch, lir_patch_low, base, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
          patch = new PatchingStub(_masm, PatchingStub::access_field_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
          patch_code = lir_patch_high;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
        __ movl(as_Address_hi(to_addr), from_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
      }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1080
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
    case T_BYTE:    // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
    case T_BOOLEAN: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
      Register src_reg = src->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
      Address dst_addr = as_Address(to_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
      assert(VM_Version::is_P6() || src_reg->has_byte_register(), "must use byte registers if not P6");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
      __ movb(dst_addr, src_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
    case T_CHAR:    // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
    case T_SHORT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
      __ movw(as_Address(to_addr), src->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
  }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1101
  if (info != NULL) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1102
    add_debug_info_for_null_check(null_check_here, info);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1103
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
  if (patch_code != lir_patch_none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
    patching_epilog(patch, patch_code, to_addr->base()->as_register(), info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
  }
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
void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
  assert(src->is_stack(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
  assert(dest->is_register(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1114
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1115
  if (dest->is_single_cpu()) {
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  1116
    if (is_reference_type(type)) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1117
      __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1118
      __ verify_oop(dest->as_register());
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1119
    } else if (type == T_METADATA) {
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13728
diff changeset
  1120
      __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1121
    } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1122
      __ movl(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
  } else if (dest->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
    Address src_addr_LO = frame_map()->address_for_slot(src->double_stack_ix(), lo_word_offset_in_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
    Address src_addr_HI = frame_map()->address_for_slot(src->double_stack_ix(), hi_word_offset_in_bytes);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1128
    __ movptr(dest->as_register_lo(), src_addr_LO);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1129
    NOT_LP64(__ movptr(dest->as_register_hi(), src_addr_HI));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
  } else if (dest->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
    Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
    __ movflt(dest->as_xmm_float_reg(), src_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
  } else if (dest->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
    Address src_addr = frame_map()->address_for_slot(src->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
    __ movdbl(dest->as_xmm_double_reg(), src_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
  } else if (dest->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
    assert(dest->fpu_regnr() == 0, "dest must be TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
    Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
    __ fld_s(src_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
  } else if (dest->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1145
    assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
    Address src_addr = frame_map()->address_for_slot(src->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
    __ fld_d(src_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1148
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
  if (src->is_single_stack()) {
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  1157
    if (is_reference_type(type)) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1158
      __ pushptr(frame_map()->address_for_slot(src ->single_stack_ix()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1159
      __ popptr (frame_map()->address_for_slot(dest->single_stack_ix()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1160
    } else {
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
  1161
#ifndef _LP64
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1162
      __ pushl(frame_map()->address_for_slot(src ->single_stack_ix()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1163
      __ popl (frame_map()->address_for_slot(dest->single_stack_ix()));
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
  1164
#else
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
  1165
      //no pushl on 64bits
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
  1166
      __ movl(rscratch1, frame_map()->address_for_slot(src ->single_stack_ix()));
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
  1167
      __ movl(frame_map()->address_for_slot(dest->single_stack_ix()), rscratch1);
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
  1168
#endif
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1169
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
  } else if (src->is_double_stack()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1172
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1173
    __ pushptr(frame_map()->address_for_slot(src ->double_stack_ix()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1174
    __ popptr (frame_map()->address_for_slot(dest->double_stack_ix()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1175
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
    __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), 0));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1177
    // push and pop the part at src + wordSize, adding wordSize for the previous push
1125
0e9a5f36b566 6746320: Hotspot regression test for 6512111 fails in -Xmixed mode
never
parents: 1066
diff changeset
  1178
    __ pushl(frame_map()->address_for_slot(src ->double_stack_ix(), 2 * wordSize));
0e9a5f36b566 6746320: Hotspot regression test for 6512111 fails in -Xmixed mode
never
parents: 1066
diff changeset
  1179
    __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 2 * wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
    __ popl (frame_map()->address_for_slot(dest->double_stack_ix(), 0));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1181
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1188
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1189
void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool wide, bool /* unaligned */) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1190
  assert(src->is_address(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1191
  assert(dest->is_register(), "should not call otherwise");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
  LIR_Address* addr = src->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1194
  Address from_addr = as_Address(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1195
21088
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20702
diff changeset
  1196
  if (addr->base()->type() == T_OBJECT) {
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20702
diff changeset
  1197
    __ verify_oop(addr->base()->as_pointer_register());
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20702
diff changeset
  1198
  }
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20702
diff changeset
  1199
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
    case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
    case T_BYTE:    // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
    case T_CHAR:    // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
    case T_SHORT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
      if (!VM_Version::is_P6() && !from_addr.uses(dest->as_register())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
        // on pre P6 processors we may get partial register stalls
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
        // so blow away the value of to_rinfo before loading a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
        // partial word into it.  Do it here so that it precedes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
        // the potential patch point below.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1210
        __ xorptr(dest->as_register(), dest->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1212
      break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 42650
diff changeset
  1213
   default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 42650
diff changeset
  1214
     break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1216
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1217
  PatchingStub* patch = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1218
  if (patch_code != lir_patch_none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1219
    patch = new PatchingStub(_masm, PatchingStub::access_field_id);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1220
    assert(from_addr.disp() != 0, "must have");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1221
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1222
  if (info != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1223
    add_debug_info_for_null_check_here(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1224
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1225
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1226
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1227
    case T_FLOAT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1228
      if (dest->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1229
        __ movflt(dest->as_xmm_float_reg(), from_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1230
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1231
        assert(dest->is_single_fpu(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1232
        assert(dest->fpu_regnr() == 0, "dest must be TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1233
        __ fld_s(from_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1235
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1236
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1237
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1238
    case T_DOUBLE: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1239
      if (dest->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1240
        __ movdbl(dest->as_xmm_double_reg(), from_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1241
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1242
        assert(dest->is_double_fpu(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1243
        assert(dest->fpu_regnrLo() == 0, "dest must be TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1244
        __ fld_d(from_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1245
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1246
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1247
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1248
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1249
    case T_OBJECT:  // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1250
    case T_ARRAY:   // fall through
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1251
      if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1252
        __ movl(dest->as_register(), from_addr);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1253
      } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1254
        __ movptr(dest->as_register(), from_addr);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1255
      }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1256
      break;
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1257
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1258
    case T_ADDRESS:
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  1259
      if (UseCompressedClassPointers && addr->disp() == oopDesc::klass_offset_in_bytes()) {
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  1260
        __ movl(dest->as_register(), from_addr);
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  1261
      } else {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  1262
        __ movptr(dest->as_register(), from_addr);
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  1263
      }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1264
      break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
    case T_INT:
5354
30df1bf62cca 6946892: c1 shouldn't sign-extend to upper 32bits on x64
iveresov
parents: 5334
diff changeset
  1266
      __ movl(dest->as_register(), from_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
    case T_LONG: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
      Register to_lo = dest->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1271
      Register to_hi = dest->as_register_hi();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1272
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1273
      __ movptr(to_lo, as_Address_lo(addr));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1274
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
      Register base = addr->base()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
      Register index = noreg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1277
      if (addr->index()->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
        index = addr->index()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1279
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1280
      if ((base == to_lo && index == to_hi) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1281
          (base == to_hi && index == to_lo)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1282
        // addresses with 2 registers are only formed as a result of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1283
        // array access so this code will never have to deal with
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1284
        // patches or null checks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1285
        assert(info == NULL && patch == NULL, "must be");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1286
        __ lea(to_hi, as_Address(addr));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
        __ movl(to_lo, Address(to_hi, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
        __ movl(to_hi, Address(to_hi, BytesPerWord));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1289
      } else if (base == to_lo || index == to_lo) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1290
        assert(base != to_hi, "can't be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1291
        assert(index == noreg || (index != base && index != to_hi), "can't handle this");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1292
        __ movl(to_hi, as_Address_hi(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1293
        if (patch != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1294
          patching_epilog(patch, lir_patch_high, base, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1295
          patch = new PatchingStub(_masm, PatchingStub::access_field_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1296
          patch_code = lir_patch_low;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1297
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1298
        __ movl(to_lo, as_Address_lo(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1299
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1300
        assert(index == noreg || (index != base && index != to_lo), "can't handle this");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1301
        __ movl(to_lo, as_Address_lo(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1302
        if (patch != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1303
          patching_epilog(patch, lir_patch_low, base, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1304
          patch = new PatchingStub(_masm, PatchingStub::access_field_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1305
          patch_code = lir_patch_high;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1306
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1307
        __ movl(to_hi, as_Address_hi(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
      }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1309
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1313
    case T_BOOLEAN: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
    case T_BYTE: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
      Register dest_reg = dest->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
      assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
      if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1318
        __ movsbl(dest_reg, from_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
        __ movb(dest_reg, from_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
        __ shll(dest_reg, 24);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
        __ sarl(dest_reg, 24);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
    case T_CHAR: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
      Register dest_reg = dest->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
      assert(VM_Version::is_P6() || dest_reg->has_byte_register(), "must use byte registers if not P6");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
      if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1331
        __ movzwl(dest_reg, from_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
        __ movw(dest_reg, from_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
    case T_SHORT: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
      Register dest_reg = dest->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
      if (VM_Version::is_P6() || from_addr.uses(dest_reg)) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1341
        __ movswl(dest_reg, from_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
        __ movw(dest_reg, from_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
        __ shll(dest_reg, 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
        __ sarl(dest_reg, 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
  if (patch != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
    patching_epilog(patch, patch_code, addr->base()->as_register(), info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  1358
  if (is_reference_type(type)) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1359
#ifdef _LP64
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1360
    if (UseCompressedOops && !wide) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1361
      __ decode_heap_oop(dest->as_register());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1362
    }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1363
#endif
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50102
diff changeset
  1364
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50102
diff changeset
  1365
    // Load barrier has not yet been applied, so ZGC can't verify the oop here
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50102
diff changeset
  1366
    if (!UseZGC) {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50102
diff changeset
  1367
      __ verify_oop(dest->as_register());
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents: 50102
diff changeset
  1368
    }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  1369
  } else if (type == T_ADDRESS && addr->disp() == oopDesc::klass_offset_in_bytes()) {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  1370
#ifdef _LP64
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  1371
    if (UseCompressedClassPointers) {
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  1372
      __ decode_klass_not_null(dest->as_register());
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  1373
    }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  1374
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
NEEDS_CLEANUP; // This could be static?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
Address::ScaleFactor LIR_Assembler::array_element_size(BasicType type) const {
202
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
  1381
  int elem_size = type2aelembytes(type);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
  switch (elem_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
    case 1: return Address::times_1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
    case 2: return Address::times_2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
    case 4: return Address::times_4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
    case 8: return Address::times_8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
  return Address::no_scale;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
void LIR_Assembler::emit_op3(LIR_Op3* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
  switch (op->code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
    case lir_idiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
    case lir_irem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
      arithmetic_idiv(op->code(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
                      op->in_opr1(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
                      op->in_opr2(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
                      op->in_opr3(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
                      op->result_opr(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
                      op->info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
      break;
41323
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1404
    case lir_fmad:
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1405
      __ fmad(op->result_opr()->as_xmm_double_reg(),
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1406
              op->in_opr1()->as_xmm_double_reg(),
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1407
              op->in_opr2()->as_xmm_double_reg(),
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1408
              op->in_opr3()->as_xmm_double_reg());
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1409
      break;
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1410
    case lir_fmaf:
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1411
      __ fmaf(op->result_opr()->as_xmm_float_reg(),
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1412
              op->in_opr1()->as_xmm_float_reg(),
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1413
              op->in_opr2()->as_xmm_float_reg(),
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1414
              op->in_opr3()->as_xmm_float_reg());
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 38033
diff changeset
  1415
      break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1416
    default:      ShouldNotReachHere(); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1417
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
void LIR_Assembler::emit_opBranch(LIR_OpBranch* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
  assert(op->block() == NULL || op->block()->label() == op->label(), "wrong label");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
  if (op->block() != NULL)  _branch_target_blocks.append(op->block());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
  if (op->ublock() != NULL) _branch_target_blocks.append(op->ublock());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
  if (op->cond() == lir_cond_always) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
    if (op->info() != NULL) add_debug_info_for_branch(op->info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
    __ jmp (*(op->label()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1430
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1431
    Assembler::Condition acond = Assembler::zero;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1432
    if (op->code() == lir_cond_float_branch) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1433
      assert(op->ublock() != NULL, "must have unordered successor");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1434
      __ jcc(Assembler::parity, *(op->ublock()->label()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1435
      switch(op->cond()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1436
        case lir_cond_equal:        acond = Assembler::equal;      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1437
        case lir_cond_notEqual:     acond = Assembler::notEqual;   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1438
        case lir_cond_less:         acond = Assembler::below;      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1439
        case lir_cond_lessEqual:    acond = Assembler::belowEqual; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1440
        case lir_cond_greaterEqual: acond = Assembler::aboveEqual; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1441
        case lir_cond_greater:      acond = Assembler::above;      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1442
        default:                         ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1443
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1444
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1445
      switch (op->cond()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1446
        case lir_cond_equal:        acond = Assembler::equal;       break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1447
        case lir_cond_notEqual:     acond = Assembler::notEqual;    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1448
        case lir_cond_less:         acond = Assembler::less;        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1449
        case lir_cond_lessEqual:    acond = Assembler::lessEqual;   break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1450
        case lir_cond_greaterEqual: acond = Assembler::greaterEqual;break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
        case lir_cond_greater:      acond = Assembler::greater;     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
        case lir_cond_belowEqual:   acond = Assembler::belowEqual;  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
        case lir_cond_aboveEqual:   acond = Assembler::aboveEqual;  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
        default:                         ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
    __ jcc(acond,*(op->label()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
  LIR_Opr src  = op->in_opr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
  LIR_Opr dest = op->result_opr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
  switch (op->bytecode()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
    case Bytecodes::_i2l:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1467
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1468
      __ movl2ptr(dest->as_register_lo(), src->as_register());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1469
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
      move_regs(src->as_register(), dest->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
      move_regs(src->as_register(), dest->as_register_hi());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
      __ sarl(dest->as_register_hi(), 31);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1473
#endif // LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
    case Bytecodes::_l2i:
12590
ab8c85fc52ea 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 11886
diff changeset
  1477
#ifdef _LP64
ab8c85fc52ea 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 11886
diff changeset
  1478
      __ movl(dest->as_register(), src->as_register_lo());
ab8c85fc52ea 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 11886
diff changeset
  1479
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
      move_regs(src->as_register_lo(), dest->as_register());
12590
ab8c85fc52ea 7160539: JDeveloper crashes on 64-bit Windows
iveresov
parents: 11886
diff changeset
  1481
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
    case Bytecodes::_i2b:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
      move_regs(src->as_register(), dest->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
      __ sign_extend_byte(dest->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
    case Bytecodes::_i2c:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
      move_regs(src->as_register(), dest->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1491
      __ andl(dest->as_register(), 0xFFFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
    case Bytecodes::_i2s:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
      move_regs(src->as_register(), dest->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
      __ sign_extend_short(dest->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
    case Bytecodes::_f2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
    case Bytecodes::_d2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
      if (dest->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
        __ cvtsd2ss(dest->as_xmm_float_reg(), src->as_xmm_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
      } else if (dest->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
        __ cvtss2sd(dest->as_xmm_double_reg(), src->as_xmm_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
        assert(src->fpu() == dest->fpu(), "register must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
        // do nothing (float result is rounded later through spilling)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
    case Bytecodes::_i2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
    case Bytecodes::_i2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
      if (dest->is_single_xmm()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1515
        __ cvtsi2ssl(dest->as_xmm_float_reg(), src->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
      } else if (dest->is_double_xmm()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1517
        __ cvtsi2sdl(dest->as_xmm_double_reg(), src->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1518
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
        assert(dest->fpu() == 0, "result must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
        __ movl(Address(rsp, 0), src->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1521
        __ fild_s(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1523
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
    case Bytecodes::_f2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
    case Bytecodes::_d2i:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
      if (src->is_single_xmm()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1528
        __ cvttss2sil(dest->as_register(), src->as_xmm_float_reg());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1529
      } else if (src->is_double_xmm()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1530
        __ cvttsd2sil(dest->as_register(), src->as_xmm_double_reg());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1531
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
        assert(src->fpu() == 0, "input must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
        __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_trunc()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1534
        __ fist_s(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1535
        __ movl(dest->as_register(), Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1536
        __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1537
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1539
      // IA32 conversion instructions do not match JLS for overflow, underflow and NaN -> fixup in stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1540
      assert(op->stub() != NULL, "stub required");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1541
      __ cmpl(dest->as_register(), 0x80000000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1542
      __ jcc(Assembler::equal, *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1543
      __ bind(*op->stub()->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1544
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1545
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1546
    case Bytecodes::_l2f:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1547
    case Bytecodes::_l2d:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1548
      assert(!dest->is_xmm_register(), "result in xmm register not supported (no SSE instruction present)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1549
      assert(dest->fpu() == 0, "result must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1550
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1551
      __ movptr(Address(rsp, 0),            src->as_register_lo());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1552
      NOT_LP64(__ movl(Address(rsp, BytesPerWord), src->as_register_hi()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1553
      __ fild_d(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1554
      // float result is rounded later through spilling
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1555
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1556
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1557
    case Bytecodes::_f2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1558
    case Bytecodes::_d2l:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1559
      assert(!src->is_xmm_register(), "input in xmm register not supported (no SSE instruction present)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1560
      assert(src->fpu() == 0, "input must be on TOS");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1561
      assert(dest == FrameMap::long0_opr, "runtime stub places result in these registers");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1562
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1563
      // instruction sequence too long to inline it here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1564
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1565
        __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::fpu2long_stub_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1566
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1567
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1568
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1569
    default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1571
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1574
  if (op->init_check()) {
48807
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 47881
diff changeset
  1575
    add_debug_info_for_null_check_here(op->stub()->info());
11407
5399831730cd 7117052: instanceKlass::_init_state can be u1 type
coleenp
parents: 10565
diff changeset
  1576
    __ cmpb(Address(op->klass()->as_register(),
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1577
                    InstanceKlass::init_state_offset()),
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1578
                    InstanceKlass::fully_initialized);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1579
    __ jcc(Assembler::notEqual, *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1580
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1581
  __ allocate_object(op->obj()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1582
                     op->tmp1()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1583
                     op->tmp2()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1584
                     op->header_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1585
                     op->object_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1586
                     op->klass()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1587
                     *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1588
  __ bind(*op->stub()->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1589
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1590
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1591
void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
7883
f29abf6b3466 7010618: C1: array length should be treated at int on 64bit during array allocation
iveresov
parents: 7713
diff changeset
  1592
  Register len =  op->len()->as_register();
f29abf6b3466 7010618: C1: array length should be treated at int on 64bit during array allocation
iveresov
parents: 7713
diff changeset
  1593
  LP64_ONLY( __ movslq(len, len); )
f29abf6b3466 7010618: C1: array length should be treated at int on 64bit during array allocation
iveresov
parents: 7713
diff changeset
  1594
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1595
  if (UseSlowPath ||
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  1596
      (!UseFastNewObjectArray && is_reference_type(op->type())) ||
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  1597
      (!UseFastNewTypeArray   && !is_reference_type(op->type()))) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1598
    __ jmp(*op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1599
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1600
    Register tmp1 = op->tmp1()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1601
    Register tmp2 = op->tmp2()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1602
    Register tmp3 = op->tmp3()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1603
    if (len == tmp1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
      tmp1 = tmp3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
    } else if (len == tmp2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1606
      tmp2 = tmp3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1607
    } else if (len == tmp3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1608
      // everything is ok
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1609
    } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1610
      __ mov(tmp3, len);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1611
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1612
    __ allocate_array(op->obj()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1613
                      len,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1614
                      tmp1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1615
                      tmp2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1616
                      arrayOopDesc::header_size(op->type()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1617
                      array_element_size(op->type()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1618
                      op->klass()->as_register(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
                      *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
  __ bind(*op->stub()->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1622
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1623
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1624
void LIR_Assembler::type_profile_helper(Register mdo,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1625
                                        ciMethodData *md, ciProfileData *data,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1626
                                        Register recv, Label* update_done) {
6478
75ef8813e3e2 6988779: c1_LIRAssembler_x86.cpp crashes VS2010 compiler
iveresov
parents: 6461
diff changeset
  1627
  for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1628
    Label next_test;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1629
    // See if the receiver is receiver[n].
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1630
    __ cmpptr(recv, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1631
    __ jccb(Assembler::notEqual, next_test);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1632
    Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1633
    __ addptr(data_addr, DataLayout::counter_increment);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1634
    __ jmp(*update_done);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1635
    __ bind(next_test);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1636
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1637
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1638
  // Didn't find receiver; find next empty slot and fill it in
6478
75ef8813e3e2 6988779: c1_LIRAssembler_x86.cpp crashes VS2010 compiler
iveresov
parents: 6461
diff changeset
  1639
  for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1640
    Label next_test;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1641
    Address recv_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)));
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1642
    __ cmpptr(recv_addr, (intptr_t)NULL_WORD);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1643
    __ jccb(Assembler::notEqual, next_test);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1644
    __ movptr(recv_addr, recv);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1645
    __ movptr(Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i))), DataLayout::counter_increment);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1646
    __ jmp(*update_done);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1647
    __ bind(next_test);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1648
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1649
}
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1650
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1651
void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, Label* failure, Label* obj_is_null) {
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1652
  // we always need a stub for the failure case.
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1653
  CodeStub* stub = op->stub();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1654
  Register obj = op->object()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1655
  Register k_RInfo = op->tmp1()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1656
  Register klass_RInfo = op->tmp2()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1657
  Register dst = op->result_opr()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1658
  ciKlass* k = op->klass();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1659
  Register Rtmp1 = noreg;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1660
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1661
  // check if it needs to be profiled
33589
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 33155
diff changeset
  1662
  ciMethodData* md = NULL;
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 33155
diff changeset
  1663
  ciProfileData* data = NULL;
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1664
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1665
  if (op->should_profile()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1666
    ciMethod* method = op->profiled_method();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1667
    assert(method != NULL, "Should have method");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1668
    int bci = op->profiled_bci();
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  1669
    md = method->method_data_or_null();
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  1670
    assert(md != NULL, "Sanity");
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1671
    data = md->bci_to_data(bci);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1672
    assert(data != NULL,                "need data for type check");
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1673
    assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1674
  }
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1675
  Label profile_cast_success, profile_cast_failure;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1676
  Label *success_target = op->should_profile() ? &profile_cast_success : success;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1677
  Label *failure_target = op->should_profile() ? &profile_cast_failure : failure;
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1678
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1679
  if (obj == k_RInfo) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1680
    k_RInfo = dst;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1681
  } else if (obj == klass_RInfo) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1682
    klass_RInfo = dst;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1683
  }
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  1684
  if (k->is_loaded() && !UseCompressedClassPointers) {
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1685
    select_different_registers(obj, dst, k_RInfo, klass_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1686
  } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1687
    Rtmp1 = op->tmp3()->as_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1688
    select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1689
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1690
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1691
  assert_different_registers(obj, k_RInfo, klass_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1692
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1693
  __ cmpptr(obj, (int32_t)NULL_WORD);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1694
  if (op->should_profile()) {
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1695
    Label not_null;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1696
    __ jccb(Assembler::notEqual, not_null);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1697
    // Object is null; update MDO and exit
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1698
    Register mdo  = klass_RInfo;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1699
    __ mov_metadata(mdo, md->constant_encoding());
50577
bf7e2684cd0a 8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents: 50525
diff changeset
  1700
    Address data_addr(mdo, md->byte_offset_of_slot(data, DataLayout::flags_offset()));
bf7e2684cd0a 8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents: 50525
diff changeset
  1701
    int header_bits = BitData::null_seen_byte_constant();
bf7e2684cd0a 8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents: 50525
diff changeset
  1702
    __ orb(data_addr, header_bits);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1703
    __ jmp(*obj_is_null);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1704
    __ bind(not_null);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1705
  } else {
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1706
    __ jcc(Assembler::equal, *obj_is_null);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1707
  }
20021
633769a06320 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 19710
diff changeset
  1708
633769a06320 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 19710
diff changeset
  1709
  if (!k->is_loaded()) {
633769a06320 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 19710
diff changeset
  1710
    klass2reg_with_patching(k_RInfo, op->info_for_patch());
633769a06320 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 19710
diff changeset
  1711
  } else {
633769a06320 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 19710
diff changeset
  1712
#ifdef _LP64
633769a06320 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 19710
diff changeset
  1713
    __ mov_metadata(k_RInfo, k->constant_encoding());
633769a06320 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 19710
diff changeset
  1714
#endif // _LP64
633769a06320 8023542: Test java/io/File/CheckPermission.java fails due to unfinished recursion (java.lang.StackOverflowError) when JIT'ed code (-client,-server) is running
iveresov
parents: 19710
diff changeset
  1715
  }
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1716
  __ verify_oop(obj);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1717
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1718
  if (op->fast_check()) {
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1719
    // get object class
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1720
    // not a safepoint as obj null check happens earlier
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1721
#ifdef _LP64
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  1722
    if (UseCompressedClassPointers) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1723
      __ load_klass(Rtmp1, obj);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1724
      __ cmpptr(k_RInfo, Rtmp1);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1725
    } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1726
      __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1727
    }
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1728
#else
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1729
    if (k->is_loaded()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1730
      __ cmpklass(Address(obj, oopDesc::klass_offset_in_bytes()), k->constant_encoding());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1731
    } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1732
      __ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1733
    }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1734
#endif
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1735
    __ jcc(Assembler::notEqual, *failure_target);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1736
    // successful cast, fall through to profile or jump
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1737
  } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1738
    // get object class
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1739
    // not a safepoint as obj null check happens earlier
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1740
    __ load_klass(klass_RInfo, obj);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1741
    if (k->is_loaded()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1742
      // See if we get an immediate positive hit
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1743
#ifdef _LP64
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1744
      __ cmpptr(k_RInfo, Address(klass_RInfo, k->super_check_offset()));
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1745
#else
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1746
      __ cmpklass(Address(klass_RInfo, k->super_check_offset()), k->constant_encoding());
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1747
#endif // _LP64
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 10565
diff changeset
  1748
      if ((juint)in_bytes(Klass::secondary_super_cache_offset()) != k->super_check_offset()) {
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1749
        __ jcc(Assembler::notEqual, *failure_target);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1750
        // successful cast, fall through to profile or jump
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1751
      } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1752
        // See if we get an immediate positive hit
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1753
        __ jcc(Assembler::equal, *success_target);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1754
        // check for self
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1755
#ifdef _LP64
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1756
        __ cmpptr(klass_RInfo, k_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1757
#else
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1758
        __ cmpklass(klass_RInfo, k->constant_encoding());
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1759
#endif // _LP64
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1760
        __ jcc(Assembler::equal, *success_target);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1761
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1762
        __ push(klass_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1763
#ifdef _LP64
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1764
        __ push(k_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1765
#else
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1766
        __ pushklass(k->constant_encoding());
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1767
#endif // _LP64
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1768
        __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1769
        __ pop(klass_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1770
        __ pop(klass_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1771
        // result is a boolean
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1772
        __ cmpl(klass_RInfo, 0);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1773
        __ jcc(Assembler::equal, *failure_target);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1774
        // successful cast, fall through to profile or jump
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1775
      }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1776
    } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1777
      // perform the fast part of the checking logic
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1778
      __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1779
      // call out-of-line instance of __ check_klass_subtype_slow_path(...):
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1780
      __ push(klass_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1781
      __ push(k_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1782
      __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1783
      __ pop(klass_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1784
      __ pop(k_RInfo);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1785
      // result is a boolean
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1786
      __ cmpl(k_RInfo, 0);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1787
      __ jcc(Assembler::equal, *failure_target);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1788
      // successful cast, fall through to profile or jump
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1789
    }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1790
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1791
  if (op->should_profile()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1792
    Register mdo  = klass_RInfo, recv = k_RInfo;
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1793
    __ bind(profile_cast_success);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1794
    __ mov_metadata(mdo, md->constant_encoding());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1795
    __ load_klass(recv, obj);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1796
    type_profile_helper(mdo, md, data, recv, success);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1797
    __ jmp(*success);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1798
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1799
    __ bind(profile_cast_failure);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1800
    __ mov_metadata(mdo, md->constant_encoding());
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1801
    Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1802
    __ subptr(counter_addr, DataLayout::counter_increment);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1803
    __ jmp(*failure);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1804
  }
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1805
  __ jmp(*success);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  1806
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1807
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1808
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1809
void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1810
  LIR_Code code = op->code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1811
  if (code == lir_store_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
    Register value = op->object()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
    Register array = op->array()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
    Register k_RInfo = op->tmp1()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
    Register klass_RInfo = op->tmp2()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
    Register Rtmp1 = op->tmp3()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
    CodeStub* stub = op->stub();
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1819
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1820
    // check if it needs to be profiled
33589
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 33155
diff changeset
  1821
    ciMethodData* md = NULL;
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 33155
diff changeset
  1822
    ciProfileData* data = NULL;
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1823
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1824
    if (op->should_profile()) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1825
      ciMethod* method = op->profiled_method();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1826
      assert(method != NULL, "Should have method");
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1827
      int bci = op->profiled_bci();
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  1828
      md = method->method_data_or_null();
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  1829
      assert(md != NULL, "Sanity");
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1830
      data = md->bci_to_data(bci);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1831
      assert(data != NULL,                "need data for type check");
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1832
      assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1833
    }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1834
    Label profile_cast_success, profile_cast_failure, done;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1835
    Label *success_target = op->should_profile() ? &profile_cast_success : &done;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1836
    Label *failure_target = op->should_profile() ? &profile_cast_failure : stub->entry();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1837
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1838
    __ cmpptr(value, (int32_t)NULL_WORD);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1839
    if (op->should_profile()) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1840
      Label not_null;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1841
      __ jccb(Assembler::notEqual, not_null);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1842
      // Object is null; update MDO and exit
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1843
      Register mdo  = klass_RInfo;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1844
      __ mov_metadata(mdo, md->constant_encoding());
50577
bf7e2684cd0a 8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents: 50525
diff changeset
  1845
      Address data_addr(mdo, md->byte_offset_of_slot(data, DataLayout::flags_offset()));
bf7e2684cd0a 8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents: 50525
diff changeset
  1846
      int header_bits = BitData::null_seen_byte_constant();
bf7e2684cd0a 8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents: 50525
diff changeset
  1847
      __ orb(data_addr, header_bits);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1848
      __ jmp(done);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1849
      __ bind(not_null);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1850
    } else {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1851
      __ jcc(Assembler::equal, done);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1852
    }
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1853
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1854
    add_debug_info_for_null_check_here(op->info_for_exception());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1855
    __ load_klass(k_RInfo, array);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1856
    __ load_klass(klass_RInfo, value);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1857
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1858
    // get instance klass (it's already uncompressed)
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13886
diff changeset
  1859
    __ movptr(k_RInfo, Address(k_RInfo, ObjArrayKlass::element_klass_offset()));
2256
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 2148
diff changeset
  1860
    // perform the fast part of the checking logic
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1861
    __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL);
2256
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 2148
diff changeset
  1862
    // call out-of-line instance of __ check_klass_subtype_slow_path(...):
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1863
    __ push(klass_RInfo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1864
    __ push(k_RInfo);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1865
    __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1866
    __ pop(klass_RInfo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1867
    __ pop(k_RInfo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1868
    // result is a boolean
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1869
    __ cmpl(k_RInfo, 0);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1870
    __ jcc(Assembler::equal, *failure_target);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1871
    // fall through to the success case
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1872
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1873
    if (op->should_profile()) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1874
      Register mdo  = klass_RInfo, recv = k_RInfo;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1875
      __ bind(profile_cast_success);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1876
      __ mov_metadata(mdo, md->constant_encoding());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1877
      __ load_klass(recv, value);
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1878
      type_profile_helper(mdo, md, data, recv, &done);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1879
      __ jmpb(done);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1880
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1881
      __ bind(profile_cast_failure);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  1882
      __ mov_metadata(mdo, md->constant_encoding());
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1883
      Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1884
      __ subptr(counter_addr, DataLayout::counter_increment);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1885
      __ jmp(*stub->entry());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
    }
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1887
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1888
    __ bind(done);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1889
  } else
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1890
    if (code == lir_checkcast) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1891
      Register obj = op->object()->as_register();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1892
      Register dst = op->result_opr()->as_register();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1893
      Label success;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1894
      emit_typecheck_helper(op, &success, op->stub()->entry(), &success);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1895
      __ bind(success);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1896
      if (dst != obj) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1897
        __ mov(dst, obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1898
      }
6461
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1899
    } else
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1900
      if (code == lir_instanceof) {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1901
        Register obj = op->object()->as_register();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1902
        Register dst = op->result_opr()->as_register();
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1903
        Label success, failure, done;
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1904
        emit_typecheck_helper(op, &success, &failure, &failure);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1905
        __ bind(failure);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1906
        __ xorptr(dst, dst);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1907
        __ jmpb(done);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1908
        __ bind(success);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1909
        __ movptr(dst, 1);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1910
        __ bind(done);
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1911
      } else {
cfc616b49f58 6919069: client compiler needs to capture more profile information for tiered work
iveresov
parents: 6460
diff changeset
  1912
        ShouldNotReachHere();
2256
82d4e10b7c6b 6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents: 2148
diff changeset
  1913
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1919
  if (LP64_ONLY(false &&) op->code() == lir_cas_long && VM_Version::supports_cx8()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
    assert(op->cmp_value()->as_register_lo() == rax, "wrong register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
    assert(op->cmp_value()->as_register_hi() == rdx, "wrong register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
    assert(op->new_value()->as_register_lo() == rbx, "wrong register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
    assert(op->new_value()->as_register_hi() == rcx, "wrong register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
    Register addr = op->addr()->as_register();
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  1925
    __ lock();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1926
    NOT_LP64(__ cmpxchg8(Address(addr, 0)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1927
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1928
  } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj ) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1929
    NOT_LP64(assert(op->addr()->is_single_cpu(), "must be single");)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1930
    Register addr = (op->addr()->is_single_cpu() ? op->addr()->as_register() : op->addr()->as_register_lo());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1931
    Register newval = op->new_value()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
    Register cmpval = op->cmp_value()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1933
    assert(cmpval == rax, "wrong register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
    assert(newval != NULL, "new val must be register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
    assert(cmpval != newval, "cmp and new values must be in different registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1936
    assert(cmpval != addr, "cmp and addr must be in different registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
    assert(newval != addr, "new value and addr must be in different registers");
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1938
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1939
    if ( op->code() == lir_cas_obj) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1940
#ifdef _LP64
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1941
      if (UseCompressedOops) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1942
        __ encode_heap_oop(cmpval);
7438
6e2a9ad88dba 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 7432
diff changeset
  1943
        __ mov(rscratch1, newval);
6e2a9ad88dba 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 7432
diff changeset
  1944
        __ encode_heap_oop(rscratch1);
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  1945
        __ lock();
7438
6e2a9ad88dba 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 7432
diff changeset
  1946
        // cmpval (rax) is implicitly used by this instruction
6e2a9ad88dba 7005241: C1: SEGV in java.util.concurrent.LinkedTransferQueue.xfer() with compressed oops
iveresov
parents: 7432
diff changeset
  1947
        __ cmpxchgl(rscratch1, Address(addr, 0));
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1948
      } else
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1949
#endif
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1950
      {
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  1951
        __ lock();
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1952
        __ cmpxchgptr(newval, Address(addr, 0));
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1953
      }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1954
    } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1955
      assert(op->code() == lir_cas_int, "lir_cas_int expected");
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  1956
      __ lock();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1957
      __ cmpxchgl(newval, Address(addr, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1958
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1959
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1960
  } else if (op->code() == lir_cas_long) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1961
    Register addr = (op->addr()->is_single_cpu() ? op->addr()->as_register() : op->addr()->as_register_lo());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1962
    Register newval = op->new_value()->as_register_lo();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1963
    Register cmpval = op->cmp_value()->as_register_lo();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1964
    assert(cmpval == rax, "wrong register");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1965
    assert(newval != NULL, "new val must be register");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1966
    assert(cmpval != newval, "cmp and new values must be in different registers");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1967
    assert(cmpval != addr, "cmp and addr must be in different registers");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1968
    assert(newval != addr, "new value and addr must be in different registers");
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  1969
    __ lock();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1970
    __ cmpxchgq(newval, Address(addr, 0));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  1971
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
    Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
7713
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7438
diff changeset
  1977
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1978
  Assembler::Condition acond, ncond;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
  switch (condition) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1980
    case lir_cond_equal:        acond = Assembler::equal;        ncond = Assembler::notEqual;     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
    case lir_cond_notEqual:     acond = Assembler::notEqual;     ncond = Assembler::equal;        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
    case lir_cond_less:         acond = Assembler::less;         ncond = Assembler::greaterEqual; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
    case lir_cond_lessEqual:    acond = Assembler::lessEqual;    ncond = Assembler::greater;      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
    case lir_cond_greaterEqual: acond = Assembler::greaterEqual; ncond = Assembler::less;         break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
    case lir_cond_greater:      acond = Assembler::greater;      ncond = Assembler::lessEqual;    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
    case lir_cond_belowEqual:   acond = Assembler::belowEqual;   ncond = Assembler::above;        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
    case lir_cond_aboveEqual:   acond = Assembler::aboveEqual;   ncond = Assembler::below;        break;
33589
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 33155
diff changeset
  1988
    default:                    acond = Assembler::equal;        ncond = Assembler::notEqual;
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 33155
diff changeset
  1989
                                ShouldNotReachHere();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1991
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
  if (opr1->is_cpu_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1993
    reg2reg(opr1, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
  } else if (opr1->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
    stack2reg(opr1, result, result->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1996
  } else if (opr1->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1997
    const2reg(opr1, result, lir_patch_none, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1998
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1999
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2000
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2001
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2002
  if (VM_Version::supports_cmov() && !opr2->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2003
    // optimized version that does not require a branch
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2004
    if (opr2->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2005
      assert(opr2->cpu_regnr() != result->cpu_regnr(), "opr2 already overwritten by previous move");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2006
      __ cmov(ncond, result->as_register(), opr2->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2007
    } else if (opr2->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2008
      assert(opr2->cpu_regnrLo() != result->cpu_regnrLo() && opr2->cpu_regnrLo() != result->cpu_regnrHi(), "opr2 already overwritten by previous move");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
      assert(opr2->cpu_regnrHi() != result->cpu_regnrLo() && opr2->cpu_regnrHi() != result->cpu_regnrHi(), "opr2 already overwritten by previous move");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2010
      __ cmovptr(ncond, result->as_register_lo(), opr2->as_register_lo());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2011
      NOT_LP64(__ cmovptr(ncond, result->as_register_hi(), opr2->as_register_hi());)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2012
    } else if (opr2->is_single_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2013
      __ cmovl(ncond, result->as_register(), frame_map()->address_for_slot(opr2->single_stack_ix()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2014
    } else if (opr2->is_double_stack()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2015
      __ cmovptr(ncond, result->as_register_lo(), frame_map()->address_for_slot(opr2->double_stack_ix(), lo_word_offset_in_bytes));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2016
      NOT_LP64(__ cmovptr(ncond, result->as_register_hi(), frame_map()->address_for_slot(opr2->double_stack_ix(), hi_word_offset_in_bytes));)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2017
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2018
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2019
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2020
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2021
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2022
    Label skip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2023
    __ jcc (acond, skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2024
    if (opr2->is_cpu_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2025
      reg2reg(opr2, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2026
    } else if (opr2->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2027
      stack2reg(opr2, result, result->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2028
    } else if (opr2->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2029
      const2reg(opr2, result, lir_patch_none, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2030
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2031
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2032
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2033
    __ bind(skip);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2034
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2035
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
void LIR_Assembler::arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest, CodeEmitInfo* info, bool pop_fpu_stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
  assert(info == NULL, "should never be used, idiv/irem and ldiv/lrem not handled by this method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
  if (left->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
    assert(left == dest, "left and dest must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2043
    Register lreg = left->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
    if (right->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2046
      // cpu register - cpu register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
      Register rreg = right->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2048
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2049
        case lir_add: __ addl (lreg, rreg); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
        case lir_sub: __ subl (lreg, rreg); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
        case lir_mul: __ imull(lreg, rreg); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
        default:      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2054
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
    } else if (right->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
      // cpu register - stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
      Address raddr = frame_map()->address_for_slot(right->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
        case lir_add: __ addl(lreg, raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
        case lir_sub: __ subl(lreg, raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
        default:      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2064
    } else if (right->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2065
      // cpu register - constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2066
      jint c = right->as_constant_ptr()->as_jint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2067
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2068
        case lir_add: {
6460
6f5143b00f4c 6984056: C1: incorrect code for integer constant addition on x64
iveresov
parents: 6453
diff changeset
  2069
          __ incrementl(lreg, c);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
        case lir_sub: {
6460
6f5143b00f4c 6984056: C1: incorrect code for integer constant addition on x64
iveresov
parents: 6453
diff changeset
  2073
          __ decrementl(lreg, c);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2078
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2080
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2081
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
  } else if (left->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
    assert(left == dest, "left and dest must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
    Register lreg_lo = left->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
    Register lreg_hi = left->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
    if (right->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
      // cpu register - cpu register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
      Register rreg_lo = right->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
      Register rreg_hi = right->as_register_hi();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2092
      NOT_LP64(assert_different_registers(lreg_lo, lreg_hi, rreg_lo, rreg_hi));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2093
      LP64_ONLY(assert_different_registers(lreg_lo, rreg_lo));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
        case lir_add:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2096
          __ addptr(lreg_lo, rreg_lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2097
          NOT_LP64(__ adcl(lreg_hi, rreg_hi));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2099
        case lir_sub:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2100
          __ subptr(lreg_lo, rreg_lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2101
          NOT_LP64(__ sbbl(lreg_hi, rreg_hi));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2102
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2103
        case lir_mul:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2104
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2105
          __ imulq(lreg_lo, rreg_lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2106
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
          assert(lreg_lo == rax && lreg_hi == rdx, "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
          __ imull(lreg_hi, rreg_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2109
          __ imull(rreg_hi, lreg_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2110
          __ addl (rreg_hi, lreg_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2111
          __ mull (rreg_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2112
          __ addl (lreg_hi, rreg_hi);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2113
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2114
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
        default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2116
          ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2117
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2118
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2119
    } else if (right->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2120
      // cpu register - constant
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2121
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2122
      jlong c = right->as_constant_ptr()->as_jlong_bits();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2123
      __ movptr(r10, (intptr_t) c);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2124
      switch (code) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2125
        case lir_add:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2126
          __ addptr(lreg_lo, r10);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2127
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2128
        case lir_sub:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2129
          __ subptr(lreg_lo, r10);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2130
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2131
        default:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2132
          ShouldNotReachHere();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2133
      }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2134
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2135
      jint c_lo = right->as_constant_ptr()->as_jint_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2136
      jint c_hi = right->as_constant_ptr()->as_jint_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2137
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2138
        case lir_add:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2139
          __ addptr(lreg_lo, c_lo);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2140
          __ adcl(lreg_hi, c_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2141
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2142
        case lir_sub:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2143
          __ subptr(lreg_lo, c_lo);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
          __ sbbl(lreg_hi, c_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2146
        default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
          ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
      }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2149
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2155
  } else if (left->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
    assert(left == dest, "left and dest must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2157
    XMMRegister lreg = left->as_xmm_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2159
    if (right->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2160
      XMMRegister rreg = right->as_xmm_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2161
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2162
        case lir_add: __ addss(lreg, rreg);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2163
        case lir_sub: __ subss(lreg, rreg);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2164
        case lir_mul_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2165
        case lir_mul: __ mulss(lreg, rreg);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2166
        case lir_div_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2167
        case lir_div: __ divss(lreg, rreg);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2168
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2169
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2170
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2171
      Address raddr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2172
      if (right->is_single_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2173
        raddr = frame_map()->address_for_slot(right->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
      } else if (right->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
        // hack for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
        raddr = __ as_Address(InternalAddress(float_constant(right->as_jfloat())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
        case lir_add: __ addss(lreg, raddr);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
        case lir_sub: __ subss(lreg, raddr);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
        case lir_mul_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
        case lir_mul: __ mulss(lreg, raddr);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
        case lir_div_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
        case lir_div: __ divss(lreg, raddr);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2187
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
  } else if (left->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
    assert(left == dest, "left and dest must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2193
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2194
    XMMRegister lreg = left->as_xmm_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2195
    if (right->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2196
      XMMRegister rreg = right->as_xmm_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2197
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2198
        case lir_add: __ addsd(lreg, rreg);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2199
        case lir_sub: __ subsd(lreg, rreg);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2200
        case lir_mul_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
        case lir_mul: __ mulsd(lreg, rreg);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
        case lir_div_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2203
        case lir_div: __ divsd(lreg, rreg);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2204
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2205
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2206
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2207
      Address raddr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2208
      if (right->is_double_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2209
        raddr = frame_map()->address_for_slot(right->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2210
      } else if (right->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2211
        // hack for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2212
        raddr = __ as_Address(InternalAddress(double_constant(right->as_jdouble())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2213
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2214
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2215
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2216
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2217
        case lir_add: __ addsd(lreg, raddr);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2218
        case lir_sub: __ subsd(lreg, raddr);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2219
        case lir_mul_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2220
        case lir_mul: __ mulsd(lreg, raddr);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2221
        case lir_div_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2222
        case lir_div: __ divsd(lreg, raddr);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2224
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
  } else if (left->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2228
    assert(dest->is_single_fpu(),  "fpu stack allocation required");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2229
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
    if (right->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
      arith_fpu_implementation(code, left->fpu_regnr(), right->fpu_regnr(), dest->fpu_regnr(), pop_fpu_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
      assert(left->fpu_regnr() == 0, "left must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
      assert(dest->fpu_regnr() == 0, "dest must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2237
      Address raddr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
      if (right->is_single_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
        raddr = frame_map()->address_for_slot(right->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2240
      } else if (right->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
        address const_addr = float_constant(right->as_jfloat());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
        assert(const_addr != NULL, "incorrect float/double constant maintainance");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2243
        // hack for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
        raddr = __ as_Address(InternalAddress(const_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
        case lir_add: __ fadd_s(raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
        case lir_sub: __ fsub_s(raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
        case lir_mul_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
        case lir_mul: __ fmul_s(raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
        case lir_div_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
        case lir_div: __ fdiv_s(raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
        default:      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2258
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2259
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
  } else if (left->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
    assert(dest->is_double_fpu(),  "fpu stack allocation required");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
    if (code == lir_mul_strictfp || code == lir_div_strictfp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
      // Double values require special handling for strictfp mul/div on x86
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
      __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias1()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
      __ fmulp(left->fpu_regnrLo() + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2269
    if (right->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
      arith_fpu_implementation(code, left->fpu_regnrLo(), right->fpu_regnrLo(), dest->fpu_regnrLo(), pop_fpu_stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2272
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
      assert(left->fpu_regnrLo() == 0, "left must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
      assert(dest->fpu_regnrLo() == 0, "dest must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2275
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
      Address raddr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
      if (right->is_double_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
        raddr = frame_map()->address_for_slot(right->double_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2279
      } else if (right->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2280
        // hack for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
        raddr = __ as_Address(InternalAddress(double_constant(right->as_jdouble())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2282
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2283
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2284
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2285
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2286
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2287
        case lir_add: __ fadd_d(raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
        case lir_sub: __ fsub_d(raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2289
        case lir_mul_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2290
        case lir_mul: __ fmul_d(raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2291
        case lir_div_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2292
        case lir_div: __ fdiv_d(raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2293
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2294
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2295
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2296
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2297
    if (code == lir_mul_strictfp || code == lir_div_strictfp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2298
      // Double values require special handling for strictfp mul/div on x86
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2299
      __ fld_x(ExternalAddress(StubRoutines::addr_fpu_subnormal_bias2()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2300
      __ fmulp(dest->fpu_regnrLo() + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2301
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2302
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2303
  } else if (left->is_single_stack() || left->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2304
    assert(left == dest, "left and dest must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2305
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2306
    Address laddr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2307
    if (left->is_single_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2308
      laddr = frame_map()->address_for_slot(left->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2309
    } else if (left->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2310
      laddr = as_Address(left->as_address_ptr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2311
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2312
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2313
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2314
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2315
    if (right->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2316
      Register rreg = right->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2317
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2318
        case lir_add: __ addl(laddr, rreg); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2319
        case lir_sub: __ subl(laddr, rreg); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2320
        default:      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2321
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2322
    } else if (right->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2323
      jint c = right->as_constant_ptr()->as_jint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2324
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2325
        case lir_add: {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2326
          __ incrementl(laddr, c);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2327
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2328
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2329
        case lir_sub: {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2330
          __ decrementl(laddr, c);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2331
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2332
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2333
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2334
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2335
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2336
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2337
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2338
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2339
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2340
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2341
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2342
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2343
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2344
void LIR_Assembler::arith_fpu_implementation(LIR_Code code, int left_index, int right_index, int dest_index, bool pop_fpu_stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2345
  assert(pop_fpu_stack  || (left_index     == dest_index || right_index     == dest_index), "invalid LIR");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2346
  assert(!pop_fpu_stack || (left_index - 1 == dest_index || right_index - 1 == dest_index), "invalid LIR");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2347
  assert(left_index == 0 || right_index == 0, "either must be on top of stack");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2348
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2349
  bool left_is_tos = (left_index == 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2350
  bool dest_is_tos = (dest_index == 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2351
  int non_tos_index = (left_is_tos ? right_index : left_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2352
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2353
  switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2354
    case lir_add:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2355
      if (pop_fpu_stack)       __ faddp(non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2356
      else if (dest_is_tos)    __ fadd (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2357
      else                     __ fadda(non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2358
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2359
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2360
    case lir_sub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2361
      if (left_is_tos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2362
        if (pop_fpu_stack)     __ fsubrp(non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2363
        else if (dest_is_tos)  __ fsub  (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2364
        else                   __ fsubra(non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2365
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2366
        if (pop_fpu_stack)     __ fsubp (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2367
        else if (dest_is_tos)  __ fsubr (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2368
        else                   __ fsuba (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2369
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2370
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2371
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2372
    case lir_mul_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2373
    case lir_mul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2374
      if (pop_fpu_stack)       __ fmulp(non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2375
      else if (dest_is_tos)    __ fmul (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2376
      else                     __ fmula(non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2377
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2378
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2379
    case lir_div_strictfp: // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2380
    case lir_div:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2381
      if (left_is_tos) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2382
        if (pop_fpu_stack)     __ fdivrp(non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2383
        else if (dest_is_tos)  __ fdiv  (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2384
        else                   __ fdivra(non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2385
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2386
        if (pop_fpu_stack)     __ fdivp (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2387
        else if (dest_is_tos)  __ fdivr (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2388
        else                   __ fdiva (non_tos_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2389
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2390
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2391
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2392
    case lir_rem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2393
      assert(left_is_tos && dest_is_tos && right_index == 1, "must be guaranteed by FPU stack allocation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2394
      __ fremr(noreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2395
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2396
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2397
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2398
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2399
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2400
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2401
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2402
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2403
void LIR_Assembler::intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr tmp, LIR_Opr dest, LIR_Op* op) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2404
  if (value->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2405
    switch(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2406
      case lir_abs :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2407
        {
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2408
#ifdef _LP64
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2409
          if (UseAVX > 2 && !VM_Version::supports_avx512vl()) {
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2410
            assert(tmp->is_valid(), "need temporary");
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2411
            __ vpandn(dest->as_xmm_double_reg(), tmp->as_xmm_double_reg(), value->as_xmm_double_reg(), 2);
51952
e374b0383035 8211272: x86_32 build failures after JDK-8210764 (Update avx512 implementation)
shade
parents: 51857
diff changeset
  2412
          } else
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2413
#endif
51952
e374b0383035 8211272: x86_32 build failures after JDK-8210764 (Update avx512 implementation)
shade
parents: 51857
diff changeset
  2414
          {
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2415
            if (dest->as_xmm_double_reg() != value->as_xmm_double_reg()) {
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2416
              __ movdbl(dest->as_xmm_double_reg(), value->as_xmm_double_reg());
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2417
            }
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2418
            assert(!tmp->is_valid(), "do not need temporary");
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2419
            __ andpd(dest->as_xmm_double_reg(),
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  2420
                     ExternalAddress((address)double_signmask_pool));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2421
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2422
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2423
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2424
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2425
      case lir_sqrt: __ sqrtsd(dest->as_xmm_double_reg(), value->as_xmm_double_reg()); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2426
      // all other intrinsics are not available in the SSE instruction set, so FPU is used
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2427
      default      : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2428
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2429
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2430
  } else if (value->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2431
    assert(value->fpu_regnrLo() == 0 && dest->fpu_regnrLo() == 0, "both must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2432
    switch(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2433
      case lir_abs   : __ fabs() ; break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2434
      case lir_sqrt  : __ fsqrt(); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2435
      default      : ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2436
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2437
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2438
    Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2439
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2440
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2441
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2442
void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2443
  // assert(left->destroys_register(), "check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2444
  if (left->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2445
    Register reg = left->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2446
    if (right->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2447
      int val = right->as_constant_ptr()->as_jint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2448
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2449
        case lir_logic_and: __ andl (reg, val); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2450
        case lir_logic_or:  __ orl  (reg, val); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2451
        case lir_logic_xor: __ xorl (reg, val); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2452
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2453
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2454
    } else if (right->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2455
      // added support for stack operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2456
      Address raddr = frame_map()->address_for_slot(right->single_stack_ix());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2457
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2458
        case lir_logic_and: __ andl (reg, raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2459
        case lir_logic_or:  __ orl  (reg, raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2460
        case lir_logic_xor: __ xorl (reg, raddr); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2461
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2462
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2463
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2464
      Register rright = right->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2465
      switch (code) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2466
        case lir_logic_and: __ andptr (reg, rright); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2467
        case lir_logic_or : __ orptr  (reg, rright); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2468
        case lir_logic_xor: __ xorptr (reg, rright); break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2469
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2470
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2471
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2472
    move_regs(reg, dst->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2473
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2474
    Register l_lo = left->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2475
    Register l_hi = left->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2476
    if (right->is_constant()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2477
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2478
      __ mov64(rscratch1, right->as_constant_ptr()->as_jlong());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2479
      switch (code) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2480
        case lir_logic_and:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2481
          __ andq(l_lo, rscratch1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2482
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2483
        case lir_logic_or:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2484
          __ orq(l_lo, rscratch1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2485
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2486
        case lir_logic_xor:
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2487
          __ xorq(l_lo, rscratch1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2488
          break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2489
        default: ShouldNotReachHere();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2490
      }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2491
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2492
      int r_lo = right->as_constant_ptr()->as_jint_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2493
      int r_hi = right->as_constant_ptr()->as_jint_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2494
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2495
        case lir_logic_and:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2496
          __ andl(l_lo, r_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2497
          __ andl(l_hi, r_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2498
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2499
        case lir_logic_or:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2500
          __ orl(l_lo, r_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2501
          __ orl(l_hi, r_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2502
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2503
        case lir_logic_xor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2504
          __ xorl(l_lo, r_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2505
          __ xorl(l_hi, r_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2506
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2507
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2508
      }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2509
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2510
    } else {
5695
7fbbde5b4e3e 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 5687
diff changeset
  2511
#ifdef _LP64
7fbbde5b4e3e 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 5687
diff changeset
  2512
      Register r_lo;
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  2513
      if (is_reference_type(right->type())) {
5695
7fbbde5b4e3e 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 5687
diff changeset
  2514
        r_lo = right->as_register();
7fbbde5b4e3e 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 5687
diff changeset
  2515
      } else {
7fbbde5b4e3e 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 5687
diff changeset
  2516
        r_lo = right->as_register_lo();
7fbbde5b4e3e 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 5687
diff changeset
  2517
      }
7fbbde5b4e3e 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 5687
diff changeset
  2518
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2519
      Register r_lo = right->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2520
      Register r_hi = right->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2521
      assert(l_lo != r_hi, "overwriting registers");
5695
7fbbde5b4e3e 6955349: C1: Make G1 barriers work with x64
iveresov
parents: 5687
diff changeset
  2522
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2523
      switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2524
        case lir_logic_and:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2525
          __ andptr(l_lo, r_lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2526
          NOT_LP64(__ andptr(l_hi, r_hi);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2527
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2528
        case lir_logic_or:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2529
          __ orptr(l_lo, r_lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2530
          NOT_LP64(__ orptr(l_hi, r_hi);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2531
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2532
        case lir_logic_xor:
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2533
          __ xorptr(l_lo, r_lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2534
          NOT_LP64(__ xorptr(l_hi, r_hi);)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2535
          break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2536
        default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2537
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2538
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2539
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2540
    Register dst_lo = dst->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2541
    Register dst_hi = dst->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2542
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2543
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2544
    move_regs(l_lo, dst_lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2545
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2546
    if (dst_lo == l_hi) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2547
      assert(dst_hi != l_lo, "overwriting registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2548
      move_regs(l_hi, dst_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2549
      move_regs(l_lo, dst_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2550
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2551
      assert(dst_lo != l_hi, "overwriting registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2552
      move_regs(l_lo, dst_lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2553
      move_regs(l_hi, dst_hi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2554
    }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2555
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2556
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2557
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2558
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2559
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2560
// we assume that rax, and rdx can be overwritten
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2561
void LIR_Assembler::arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr temp, LIR_Opr result, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2562
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2563
  assert(left->is_single_cpu(),   "left must be register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2564
  assert(right->is_single_cpu() || right->is_constant(),  "right must be register or constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2565
  assert(result->is_single_cpu(), "result must be register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2566
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2567
  //  assert(left->destroys_register(), "check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2568
  //  assert(right->destroys_register(), "check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2569
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2570
  Register lreg = left->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2571
  Register dreg = result->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2572
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2573
  if (right->is_constant()) {
52675
7d3cde494494 8214206: Fix for JDK-8213419 is broken on 32-bit
roland
parents: 51996
diff changeset
  2574
    jint divisor = right->as_constant_ptr()->as_jint();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2575
    assert(divisor > 0 && is_power_of_2(divisor), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2576
    if (code == lir_idiv) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2577
      assert(lreg == rax, "must be rax,");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2578
      assert(temp->as_register() == rdx, "tmp register must be rdx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2579
      __ cdql(); // sign extend into rdx:rax
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2580
      if (divisor == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2581
        __ subl(lreg, rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2582
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2583
        __ andl(rdx, divisor - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2584
        __ addl(lreg, rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2585
      }
52675
7d3cde494494 8214206: Fix for JDK-8213419 is broken on 32-bit
roland
parents: 51996
diff changeset
  2586
      __ sarl(lreg, log2_jint(divisor));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2587
      move_regs(lreg, dreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2588
    } else if (code == lir_irem) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2589
      Label done;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2590
      __ mov(dreg, lreg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2591
      __ andl(dreg, 0x80000000 | (divisor - 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2592
      __ jcc(Assembler::positive, done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2593
      __ decrement(dreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2594
      __ orl(dreg, ~(divisor - 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2595
      __ increment(dreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2596
      __ bind(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2597
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2598
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2599
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2600
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2601
    Register rreg = right->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2602
    assert(lreg == rax, "left register must be rax,");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2603
    assert(rreg != rdx, "right register must not be rdx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2604
    assert(temp->as_register() == rdx, "tmp register must be rdx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2605
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2606
    move_regs(lreg, rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2607
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2608
    int idivl_offset = __ corrected_idivl(rreg);
48807
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 47881
diff changeset
  2609
    if (ImplicitDiv0Checks) {
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 47881
diff changeset
  2610
      add_debug_info_for_div0(idivl_offset, info);
fd8ccb37fce9 8195776: [x86,sparc] A row of minor fixes and enhancements.
goetz
parents: 47881
diff changeset
  2611
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2612
    if (code == lir_irem) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2613
      move_regs(rdx, dreg); // result is in rdx
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2614
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2615
      move_regs(rax, dreg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2616
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2617
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2618
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2619
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2620
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2621
void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2622
  if (opr1->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2623
    Register reg1 = opr1->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2624
    if (opr2->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2625
      // cpu register - cpu register
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  2626
      if (is_reference_type(opr1->type())) {
47683
f433d49aceb4 8184914: Use MacroAssembler::cmpoop() consistently when comparing heap objects
rkennke
parents: 47216
diff changeset
  2627
        __ cmpoop(reg1, opr2->as_register());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2628
      } else {
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  2629
        assert(!is_reference_type(opr2->type()), "cmp int, oop?");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2630
        __ cmpl(reg1, opr2->as_register());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2631
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2632
    } else if (opr2->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2633
      // cpu register - stack
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  2634
      if (is_reference_type(opr1->type())) {
47683
f433d49aceb4 8184914: Use MacroAssembler::cmpoop() consistently when comparing heap objects
rkennke
parents: 47216
diff changeset
  2635
        __ cmpoop(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2636
      } else {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2637
        __ cmpl(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2638
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2639
    } else if (opr2->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2640
      // cpu register - constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2641
      LIR_Const* c = opr2->as_constant_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2642
      if (c->type() == T_INT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2643
        __ cmpl(reg1, c->as_jint());
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  2644
      } else if (is_reference_type(c->type())) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2645
        // In 64bit oops are single register
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2646
        jobject o = c->as_jobject();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2647
        if (o == NULL) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2648
          __ cmpptr(reg1, (int32_t)NULL_WORD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2649
        } else {
47683
f433d49aceb4 8184914: Use MacroAssembler::cmpoop() consistently when comparing heap objects
rkennke
parents: 47216
diff changeset
  2650
          __ cmpoop(reg1, o);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2651
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2652
      } else {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32727
diff changeset
  2653
        fatal("unexpected type: %s", basictype_to_str(c->type()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2654
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2655
      // cpu register - address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2656
    } else if (opr2->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2657
      if (op->info() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2658
        add_debug_info_for_null_check_here(op->info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2659
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2660
      __ cmpl(reg1, as_Address(opr2->as_address_ptr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2661
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2662
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2663
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2664
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2665
  } else if(opr1->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2666
    Register xlo = opr1->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2667
    Register xhi = opr1->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2668
    if (opr2->is_double_cpu()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2669
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2670
      __ cmpptr(xlo, opr2->as_register_lo());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2671
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2672
      // cpu register - cpu register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2673
      Register ylo = opr2->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2674
      Register yhi = opr2->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2675
      __ subl(xlo, ylo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2676
      __ sbbl(xhi, yhi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2677
      if (condition == lir_cond_equal || condition == lir_cond_notEqual) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2678
        __ orl(xhi, xlo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2679
      }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2680
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2681
    } else if (opr2->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2682
      // cpu register - constant 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2683
      assert(opr2->as_jlong() == (jlong)0, "only handles zero");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2684
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2685
      __ cmpptr(xlo, (int32_t)opr2->as_jlong());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2686
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2687
      assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "only handles equals case");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2688
      __ orl(xhi, xlo);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2689
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2690
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2691
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2692
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2693
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2694
  } else if (opr1->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2695
    XMMRegister reg1 = opr1->as_xmm_float_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2696
    if (opr2->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2697
      // xmm register - xmm register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2698
      __ ucomiss(reg1, opr2->as_xmm_float_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2699
    } else if (opr2->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2700
      // xmm register - stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2701
      __ ucomiss(reg1, frame_map()->address_for_slot(opr2->single_stack_ix()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2702
    } else if (opr2->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2703
      // xmm register - constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2704
      __ ucomiss(reg1, InternalAddress(float_constant(opr2->as_jfloat())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2705
    } else if (opr2->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2706
      // xmm register - address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2707
      if (op->info() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2708
        add_debug_info_for_null_check_here(op->info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2709
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2710
      __ ucomiss(reg1, as_Address(opr2->as_address_ptr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2711
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2712
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2713
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2714
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2715
  } else if (opr1->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2716
    XMMRegister reg1 = opr1->as_xmm_double_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2717
    if (opr2->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2718
      // xmm register - xmm register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2719
      __ ucomisd(reg1, opr2->as_xmm_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2720
    } else if (opr2->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2721
      // xmm register - stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2722
      __ ucomisd(reg1, frame_map()->address_for_slot(opr2->double_stack_ix()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2723
    } else if (opr2->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2724
      // xmm register - constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2725
      __ ucomisd(reg1, InternalAddress(double_constant(opr2->as_jdouble())));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2726
    } else if (opr2->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2727
      // xmm register - address
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2728
      if (op->info() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2729
        add_debug_info_for_null_check_here(op->info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2730
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2731
      __ ucomisd(reg1, as_Address(opr2->pointer()->as_address()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2732
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2733
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2734
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2735
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2736
  } else if(opr1->is_single_fpu() || opr1->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2737
    assert(opr1->is_fpu_register() && opr1->fpu() == 0, "currently left-hand side must be on TOS (relax this restriction)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2738
    assert(opr2->is_fpu_register(), "both must be registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2739
    __ fcmp(noreg, opr2->fpu(), op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2740
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2741
  } else if (opr1->is_address() && opr2->is_constant()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2742
    LIR_Const* c = opr2->as_constant_ptr();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2743
#ifdef _LP64
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  2744
    if (is_reference_type(c->type())) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2745
      assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "need to reverse");
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2746
      __ movoop(rscratch1, c->as_jobject());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2747
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2748
#endif // LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2749
    if (op->info() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2750
      add_debug_info_for_null_check_here(op->info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2751
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2752
    // special case: address - constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2753
    LIR_Address* addr = opr1->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2754
    if (c->type() == T_INT) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2755
      __ cmpl(as_Address(addr), c->as_jint());
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  2756
    } else if (is_reference_type(c->type())) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2757
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2758
      // %%% Make this explode if addr isn't reachable until we figure out a
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2759
      // better strategy by giving noreg as the temp for as_Address
47683
f433d49aceb4 8184914: Use MacroAssembler::cmpoop() consistently when comparing heap objects
rkennke
parents: 47216
diff changeset
  2760
      __ cmpoop(rscratch1, as_Address(addr, noreg));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2761
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2762
      __ cmpoop(as_Address(addr), c->as_jobject());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2763
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2764
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2765
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2766
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2767
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2768
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2769
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2770
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2771
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2772
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2773
void LIR_Assembler::comp_fl2i(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst, LIR_Op2* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2774
  if (code == lir_cmp_fd2i || code == lir_ucmp_fd2i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2775
    if (left->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2776
      assert(right->is_single_xmm(), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2777
      __ cmpss2int(left->as_xmm_float_reg(), right->as_xmm_float_reg(), dst->as_register(), code == lir_ucmp_fd2i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2778
    } else if (left->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2779
      assert(right->is_double_xmm(), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2780
      __ cmpsd2int(left->as_xmm_double_reg(), right->as_xmm_double_reg(), dst->as_register(), code == lir_ucmp_fd2i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2781
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2782
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2783
      assert(left->is_single_fpu() || left->is_double_fpu(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2784
      assert(right->is_single_fpu() || right->is_double_fpu(), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2785
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2786
      assert(left->fpu() == 0, "left must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2787
      __ fcmp2int(dst->as_register(), code == lir_ucmp_fd2i, right->fpu(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2788
                  op->fpu_pop_count() > 0, op->fpu_pop_count() > 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2789
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2790
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2791
    assert(code == lir_cmp_l2i, "check");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2792
#ifdef _LP64
5253
d2c37eee9a65 6942223: c1 64 bit fixes
iveresov
parents: 5052
diff changeset
  2793
    Label done;
d2c37eee9a65 6942223: c1 64 bit fixes
iveresov
parents: 5052
diff changeset
  2794
    Register dest = dst->as_register();
d2c37eee9a65 6942223: c1 64 bit fixes
iveresov
parents: 5052
diff changeset
  2795
    __ cmpptr(left->as_register_lo(), right->as_register_lo());
d2c37eee9a65 6942223: c1 64 bit fixes
iveresov
parents: 5052
diff changeset
  2796
    __ movl(dest, -1);
d2c37eee9a65 6942223: c1 64 bit fixes
iveresov
parents: 5052
diff changeset
  2797
    __ jccb(Assembler::less, done);
d2c37eee9a65 6942223: c1 64 bit fixes
iveresov
parents: 5052
diff changeset
  2798
    __ set_byte_if_not_zero(dest);
d2c37eee9a65 6942223: c1 64 bit fixes
iveresov
parents: 5052
diff changeset
  2799
    __ movzbl(dest, dest);
d2c37eee9a65 6942223: c1 64 bit fixes
iveresov
parents: 5052
diff changeset
  2800
    __ bind(done);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2801
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2802
    __ lcmp2int(left->as_register_hi(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2803
                left->as_register_lo(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2804
                right->as_register_hi(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2805
                right->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2806
    move_regs(left->as_register_hi(), dst->as_register());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2807
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2808
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2809
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2810
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2811
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2812
void LIR_Assembler::align_call(LIR_Code code) {
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2813
  // make sure that the displacement word of the call ends up word aligned
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2814
  int offset = __ offset();
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2815
  switch (code) {
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2816
  case lir_static_call:
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2817
  case lir_optvirtual_call:
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2818
  case lir_dynamic_call:
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2819
    offset += NativeCall::displacement_offset;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2820
    break;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2821
  case lir_icvirtual_call:
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2822
    offset += NativeCall::displacement_offset + NativeMovConstReg::instruction_size;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2823
    break;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2824
  case lir_virtual_call:  // currently, sparc-specific for niagara
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2825
  default: ShouldNotReachHere();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2826
  }
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2827
  __ align(BytesPerWord, offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2828
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2829
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2830
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
  2831
void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) {
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2832
  assert((__ offset() + NativeCall::displacement_offset) % BytesPerWord == 0,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2833
         "must be aligned");
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
  2834
  __ call(AddressLiteral(op->addr(), rtype));
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5404
diff changeset
  2835
  add_call_info(code_offset(), op->info());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2836
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2837
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2838
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
  2839
void LIR_Assembler::ic_call(LIR_OpJavaCall* op) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2840
  __ ic_call(op->addr());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2841
  add_call_info(code_offset(), op->info());
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2842
  assert((__ offset() - NativeCall::instruction_size + NativeCall::displacement_offset) % BytesPerWord == 0,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2843
         "must be aligned");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2844
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2845
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2846
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2847
/* Currently, vtable-dispatch is only enabled for sparc platforms */
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
  2848
void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2849
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2850
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2851
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4898
diff changeset
  2852
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2853
void LIR_Assembler::emit_static_call_stub() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2854
  address call_pc = __ pc();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2855
  address stub = __ start_a_stub(call_stub_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2856
  if (stub == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2857
    bailout("static call stub overflow");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2858
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2859
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2860
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2861
  int start = __ offset();
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2862
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2863
  // make sure that the displacement word of the call ends up word aligned
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2864
  __ align(BytesPerWord, __ offset() + NativeMovConstReg::instruction_size + NativeCall::displacement_offset);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2865
  __ relocate(static_stub_Relocation::spec(call_pc, false /* is_aot */));
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  2866
  __ mov_metadata(rbx, (Metadata*)NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2867
  // must be set to -1 at code generation time
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  2868
  assert(((__ offset() + 1) % BytesPerWord) == 0, "must be aligned");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2869
  // On 64bit this will die since it will take a movq & jmp, must be only a jmp
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2870
  __ jump(RuntimeAddress(__ pc()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2871
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2872
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2873
    // Trampoline to aot code
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2874
    __ relocate(static_stub_Relocation::spec(call_pc, true /* is_aot */));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2875
#ifdef _LP64
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2876
    __ mov64(rax, CONST64(0));  // address is zapped till fixup time.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2877
#else
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2878
    __ movl(rax, 0xdeadffff);  // address is zapped till fixup time.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2879
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2880
    __ jmp(rax);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2881
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42086
diff changeset
  2882
  assert(__ offset() - start <= call_stub_size(), "stub too big");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2883
  __ end_a_stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2884
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2885
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2886
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2887
void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2888
  assert(exceptionOop->as_register() == rax, "must match");
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2889
  assert(exceptionPC->as_register() == rdx, "must match");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2890
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2891
  // exception object is not added to oop map by LinearScan
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2892
  // (LinearScan assumes that no oops are in fixed registers)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2893
  info->add_register_oop(exceptionOop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2894
  Runtime1::StubID unwind_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2895
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2896
  // get current pc information
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2897
  // pc is only needed if the method has an exception handler, the unwind code does not need it.
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2898
  int pc_for_athrow_offset = __ offset();
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2899
  InternalAddress pc_for_athrow(__ pc());
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2900
  __ lea(exceptionPC->as_register(), pc_for_athrow);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2901
  add_call_info(pc_for_athrow_offset, info); // for exception handler
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2902
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2903
  __ verify_not_null_oop(rax);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2904
  // search an exception handler (rax: exception oop, rdx: throwing pc)
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2905
  if (compilation()->has_fpu_code()) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2906
    unwind_id = Runtime1::handle_exception_id;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2907
  } else {
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2908
    unwind_id = Runtime1::handle_exception_nofpu_id;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2909
  }
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2910
  __ call(RuntimeAddress(Runtime1::entry_for(unwind_id)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2911
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2912
  // enough room for two byte trap
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2913
  __ nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2914
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2915
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2916
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2917
void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2918
  assert(exceptionOop->as_register() == rax, "must match");
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2919
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2920
  __ jmp(_unwind_handler_entry);
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2921
}
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2922
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5253
diff changeset
  2923
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2924
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, LIR_Opr count, LIR_Opr dest, LIR_Opr tmp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2925
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2926
  // optimized version for linear scan:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2927
  // * count must be already in ECX (guaranteed by LinearScan)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2928
  // * left and dest must be equal
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2929
  // * tmp must be unused
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2930
  assert(count->as_register() == SHIFT_count, "count must be in ECX");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2931
  assert(left == dest, "left and dest must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2932
  assert(tmp->is_illegal(), "wasting a register if tmp is allocated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2933
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2934
  if (left->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2935
    Register value = left->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2936
    assert(value != SHIFT_count, "left cannot be ECX");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2937
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2938
    switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2939
      case lir_shl:  __ shll(value); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2940
      case lir_shr:  __ sarl(value); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2941
      case lir_ushr: __ shrl(value); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2942
      default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2943
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2944
  } else if (left->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2945
    Register lo = left->as_register_lo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2946
    Register hi = left->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2947
    assert(lo != SHIFT_count && hi != SHIFT_count, "left cannot be ECX");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2948
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2949
    switch (code) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2950
      case lir_shl:  __ shlptr(lo);        break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2951
      case lir_shr:  __ sarptr(lo);        break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2952
      case lir_ushr: __ shrptr(lo);        break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2953
      default: ShouldNotReachHere();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2954
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2955
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2956
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2957
    switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2958
      case lir_shl:  __ lshl(hi, lo);        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2959
      case lir_shr:  __ lshr(hi, lo, true);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2960
      case lir_ushr: __ lshr(hi, lo, false); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2961
      default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2962
    }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2963
#endif // LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2964
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2965
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2966
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2967
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2968
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2969
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2970
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2971
  if (dest->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2972
    // first move left into dest so that left is not destroyed by the shift
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2973
    Register value = dest->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2974
    count = count & 0x1F; // Java spec
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2975
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2976
    move_regs(left->as_register(), value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2977
    switch (code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2978
      case lir_shl:  __ shll(value, count); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2979
      case lir_shr:  __ sarl(value, count); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2980
      case lir_ushr: __ shrl(value, count); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2981
      default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2982
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2983
  } else if (dest->is_double_cpu()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2984
#ifndef _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2985
    Unimplemented();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2986
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2987
    // first move left into dest so that left is not destroyed by the shift
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2988
    Register value = dest->as_register_lo();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2989
    count = count & 0x1F; // Java spec
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2990
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2991
    move_regs(left->as_register_lo(), value);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2992
    switch (code) {
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2993
      case lir_shl:  __ shlptr(value, count); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2994
      case lir_shr:  __ sarptr(value, count); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2995
      case lir_ushr: __ shrptr(value, count); break;
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2996
      default: ShouldNotReachHere();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2997
    }
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  2998
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2999
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3000
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3001
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3002
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3003
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3004
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3005
void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3006
  assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3007
  int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3008
  assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3009
  __ movptr (Address(rsp, offset_from_rsp_in_bytes), r);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3010
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3011
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3012
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3013
void LIR_Assembler::store_parameter(jint c,     int offset_from_rsp_in_words) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3014
  assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3015
  int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3016
  assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3017
  __ movptr (Address(rsp, offset_from_rsp_in_bytes), c);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3018
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3019
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3020
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3021
void LIR_Assembler::store_parameter(jobject o,  int offset_from_rsp_in_words) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3022
  assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3023
  int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3024
  assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3025
  __ movoop (Address(rsp, offset_from_rsp_in_bytes), o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3026
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3027
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3028
34200
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3029
void LIR_Assembler::store_parameter(Metadata* m,  int offset_from_rsp_in_words) {
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3030
  assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3031
  int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3032
  assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3033
  __ mov_metadata(Address(rsp, offset_from_rsp_in_bytes), m);
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3034
}
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3035
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3036
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3037
// This code replaces a call to arraycopy; no exception may
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3038
// be thrown in this code, they must be thrown in the System.arraycopy
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3039
// activation frame; we could save some checks if this would not be the case
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3040
void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3041
  ciArrayKlass* default_type = op->expected_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3042
  Register src = op->src()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3043
  Register dst = op->dst()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3044
  Register src_pos = op->src_pos()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3045
  Register dst_pos = op->dst_pos()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3046
  Register length  = op->length()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3047
  Register tmp = op->tmp()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3048
51469
8a9e5819eab5 8209668: Explicit barriers for C1/assembler
rkennke
parents: 50577
diff changeset
  3049
  __ resolve(ACCESS_READ, src);
8a9e5819eab5 8209668: Explicit barriers for C1/assembler
rkennke
parents: 50577
diff changeset
  3050
  __ resolve(ACCESS_WRITE, dst);
8a9e5819eab5 8209668: Explicit barriers for C1/assembler
rkennke
parents: 50577
diff changeset
  3051
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3052
  CodeStub* stub = op->stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3053
  int flags = op->flags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3054
  BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 55253
diff changeset
  3055
  if (is_reference_type(basic_type)) basic_type = T_OBJECT;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3056
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3057
  // if we don't know anything, just go through the generic arraycopy
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3058
  if (default_type == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3059
    // save outgoing arguments on stack in case call to System.arraycopy is needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3060
    // HACK ALERT. This code used to push the parameters in a hardwired fashion
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3061
    // for interpreter calling conventions. Now we have to do it in new style conventions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3062
    // For the moment until C1 gets the new register allocator I just force all the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3063
    // args to the right place (except the register args) and then on the back side
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3064
    // reload the register args properly if we go slow path. Yuck
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3065
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3066
    // These are proper for the calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3067
    store_parameter(length, 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3068
    store_parameter(dst_pos, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3069
    store_parameter(dst, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3070
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3071
    // these are just temporary placements until we need to reload
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3072
    store_parameter(src_pos, 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3073
    store_parameter(src, 4);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3074
    NOT_LP64(assert(src == rcx && src_pos == rdx, "mismatch in calling convention");)
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3075
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3076
    address copyfunc_addr = StubRoutines::generic_arraycopy();
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3077
    assert(copyfunc_addr != NULL, "generic arraycopy stub required");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3078
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3079
    // pass arguments: may push as this is not a safepoint; SP must be fix at each safepoint
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3080
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3081
    // The arguments are in java calling convention so we can trivially shift them to C
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3082
    // convention
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3083
    assert_different_registers(c_rarg0, j_rarg1, j_rarg2, j_rarg3, j_rarg4);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3084
    __ mov(c_rarg0, j_rarg0);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3085
    assert_different_registers(c_rarg1, j_rarg2, j_rarg3, j_rarg4);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3086
    __ mov(c_rarg1, j_rarg1);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3087
    assert_different_registers(c_rarg2, j_rarg3, j_rarg4);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3088
    __ mov(c_rarg2, j_rarg2);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3089
    assert_different_registers(c_rarg3, j_rarg4);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3090
    __ mov(c_rarg3, j_rarg3);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3091
#ifdef _WIN64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3092
    // Allocate abi space for args but be sure to keep stack aligned
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3093
    __ subptr(rsp, 6*wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3094
    store_parameter(j_rarg4, 4);
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3095
#ifndef PRODUCT
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3096
    if (PrintC1Statistics) {
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3097
      __ incrementl(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3098
    }
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3099
#endif
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3100
    __ call(RuntimeAddress(copyfunc_addr));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3101
    __ addptr(rsp, 6*wordSize);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3102
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3103
    __ mov(c_rarg4, j_rarg4);
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3104
#ifndef PRODUCT
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3105
    if (PrintC1Statistics) {
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3106
      __ incrementl(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3107
    }
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3108
#endif
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3109
    __ call(RuntimeAddress(copyfunc_addr));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3110
#endif // _WIN64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3111
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3112
    __ push(length);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3113
    __ push(dst_pos);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3114
    __ push(dst);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3115
    __ push(src_pos);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3116
    __ push(src);
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3117
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3118
#ifndef PRODUCT
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3119
    if (PrintC1Statistics) {
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3120
      __ incrementl(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3121
    }
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3122
#endif
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3123
    __ call_VM_leaf(copyfunc_addr, 5); // removes pushed parameter from the stack
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3124
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3125
#endif // _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3126
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3127
    __ cmpl(rax, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3128
    __ jcc(Assembler::equal, *stub->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3129
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3130
    __ mov(tmp, rax);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3131
    __ xorl(tmp, -1);
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3132
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3133
    // Reload values from the stack so they are where the stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3134
    // expects them.
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3135
    __ movptr   (dst,     Address(rsp, 0*BytesPerWord));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3136
    __ movptr   (dst_pos, Address(rsp, 1*BytesPerWord));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3137
    __ movptr   (length,  Address(rsp, 2*BytesPerWord));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3138
    __ movptr   (src_pos, Address(rsp, 3*BytesPerWord));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3139
    __ movptr   (src,     Address(rsp, 4*BytesPerWord));
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3140
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3141
    __ subl(length, tmp);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3142
    __ addl(src_pos, tmp);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  3143
    __ addl(dst_pos, tmp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3144
    __ jmp(*stub->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3145
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3146
    __ bind(*stub->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3147
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3148
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3149
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3150
  assert(default_type != NULL && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3151
202
dc13bf0e5d5d 6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents: 1
diff changeset
  3152
  int elem_size = type2aelembytes(basic_type);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3153
  Address::ScaleFactor scale;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3154
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3155
  switch (elem_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3156
    case 1 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3157
      scale = Address::times_1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3158
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3159
    case 2 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3160
      scale = Address::times_2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3161
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3162
    case 4 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3163
      scale = Address::times_4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3164
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3165
    case 8 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3166
      scale = Address::times_8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3167
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3168
    default:
33589
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 33155
diff changeset
  3169
      scale = Address::no_scale;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3170
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3171
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3172
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3173
  Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3174
  Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3175
  Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3176
  Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3177
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3178
  // length and pos's are all sign extended at this point on 64bit
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3179
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3180
  // test for NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3181
  if (flags & LIR_OpArrayCopy::src_null_check) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3182
    __ testptr(src, src);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3183
    __ jcc(Assembler::zero, *stub->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3184
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3185
  if (flags & LIR_OpArrayCopy::dst_null_check) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3186
    __ testptr(dst, dst);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3187
    __ jcc(Assembler::zero, *stub->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3188
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3189
41543
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3190
  // If the compiler was not able to prove that exact type of the source or the destination
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3191
  // of the arraycopy is an array type, check at runtime if the source or the destination is
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3192
  // an instance type.
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3193
  if (flags & LIR_OpArrayCopy::type_check) {
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3194
    if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3195
      __ load_klass(tmp, dst);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3196
      __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3197
      __ jcc(Assembler::greaterEqual, *stub->entry());
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3198
    }
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3199
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3200
    if (!(flags & LIR_OpArrayCopy::src_objarray)) {
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3201
      __ load_klass(tmp, src);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3202
      __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value);
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3203
      __ jcc(Assembler::greaterEqual, *stub->entry());
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3204
    }
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3205
  }
92f720daf12d 8160591: Improve internal array handling
zmajo
parents: 41323
diff changeset
  3206
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3207
  // check if negative
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3208
  if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3209
    __ testl(src_pos, src_pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3210
    __ jcc(Assembler::less, *stub->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3211
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3212
  if (flags & LIR_OpArrayCopy::dst_pos_positive_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3213
    __ testl(dst_pos, dst_pos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3214
    __ jcc(Assembler::less, *stub->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3216
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3217
  if (flags & LIR_OpArrayCopy::src_range_check) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3218
    __ lea(tmp, Address(src_pos, length, Address::times_1, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3219
    __ cmpl(tmp, src_length_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3220
    __ jcc(Assembler::above, *stub->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3221
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3222
  if (flags & LIR_OpArrayCopy::dst_range_check) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3223
    __ lea(tmp, Address(dst_pos, length, Address::times_1, 0));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3224
    __ cmpl(tmp, dst_length_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3225
    __ jcc(Assembler::above, *stub->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3226
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3227
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3228
  if (flags & LIR_OpArrayCopy::length_positive_check) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3229
    __ testl(length, length);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3230
    __ jcc(Assembler::less, *stub->entry());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3231
  }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3232
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3233
#ifdef _LP64
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3234
  __ movl2ptr(src_pos, src_pos); //higher 32bits must be null
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3235
  __ movl2ptr(dst_pos, dst_pos); //higher 32bits must be null
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3236
#endif
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3237
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3238
  if (flags & LIR_OpArrayCopy::type_check) {
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3239
    // We don't know the array types are compatible
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3240
    if (basic_type != T_OBJECT) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3241
      // Simple test for basic type arrays
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  3242
      if (UseCompressedClassPointers) {
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3243
        __ movl(tmp, src_klass_addr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3244
        __ cmpl(tmp, dst_klass_addr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3245
      } else {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3246
        __ movptr(tmp, src_klass_addr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3247
        __ cmpptr(tmp, dst_klass_addr);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3248
      }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3249
      __ jcc(Assembler::notEqual, *stub->entry());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3250
    } else {
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3251
      // For object arrays, if src is a sub class of dst then we can
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3252
      // safely do the copy.
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3253
      Label cont, slow;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3254
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3255
      __ push(src);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3256
      __ push(dst);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3257
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3258
      __ load_klass(src, src);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3259
      __ load_klass(dst, dst);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3260
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3261
      __ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, NULL);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3262
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3263
      __ push(src);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3264
      __ push(dst);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3265
      __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3266
      __ pop(dst);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3267
      __ pop(src);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3268
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3269
      __ cmpl(src, 0);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3270
      __ jcc(Assembler::notEqual, cont);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3271
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3272
      __ bind(slow);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3273
      __ pop(dst);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3274
      __ pop(src);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3275
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3276
      address copyfunc_addr = StubRoutines::checkcast_arraycopy();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3277
      if (copyfunc_addr != NULL) { // use stub if available
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3278
        // src is not a sub class of dst so we have to do a
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3279
        // per-element check.
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3280
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3281
        int mask = LIR_OpArrayCopy::src_objarray|LIR_OpArrayCopy::dst_objarray;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3282
        if ((flags & mask) != mask) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3283
          // Check that at least both of them object arrays.
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3284
          assert(flags & mask, "one of the two should be known to be an object array");
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3285
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3286
          if (!(flags & LIR_OpArrayCopy::src_objarray)) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3287
            __ load_klass(tmp, src);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3288
          } else if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3289
            __ load_klass(tmp, dst);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3290
          }
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 10565
diff changeset
  3291
          int lh_offset = in_bytes(Klass::layout_helper_offset());
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3292
          Address klass_lh_addr(tmp, lh_offset);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3293
          jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3294
          __ cmpl(klass_lh_addr, objArray_lh);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3295
          __ jcc(Assembler::notEqual, *stub->entry());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3296
        }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3297
9962
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3298
       // Spill because stubs can use any register they like and it's
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3299
       // easier to restore just those that we care about.
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3300
       store_parameter(dst, 0);
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3301
       store_parameter(dst_pos, 1);
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3302
       store_parameter(length, 2);
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3303
       store_parameter(src_pos, 3);
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3304
       store_parameter(src, 4);
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3305
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3306
#ifndef _LP64
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3307
        __ movptr(tmp, dst_klass_addr);
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13886
diff changeset
  3308
        __ movptr(tmp, Address(tmp, ObjArrayKlass::element_klass_offset()));
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3309
        __ push(tmp);
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 10565
diff changeset
  3310
        __ movl(tmp, Address(tmp, Klass::super_check_offset_offset()));
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3311
        __ push(tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3312
        __ push(length);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3313
        __ lea(tmp, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3314
        __ push(tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3315
        __ lea(tmp, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3316
        __ push(tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3317
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3318
        __ call_VM_leaf(copyfunc_addr, 5);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3319
#else
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3320
        __ movl2ptr(length, length); //higher 32bits must be null
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3321
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3322
        __ lea(c_rarg0, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3323
        assert_different_registers(c_rarg0, dst, dst_pos, length);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3324
        __ lea(c_rarg1, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3325
        assert_different_registers(c_rarg1, dst, length);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3326
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3327
        __ mov(c_rarg2, length);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3328
        assert_different_registers(c_rarg2, dst);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3329
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3330
#ifdef _WIN64
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3331
        // Allocate abi space for args but be sure to keep stack aligned
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3332
        __ subptr(rsp, 6*wordSize);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3333
        __ load_klass(c_rarg3, dst);
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13886
diff changeset
  3334
        __ movptr(c_rarg3, Address(c_rarg3, ObjArrayKlass::element_klass_offset()));
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3335
        store_parameter(c_rarg3, 4);
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 10565
diff changeset
  3336
        __ movl(c_rarg3, Address(c_rarg3, Klass::super_check_offset_offset()));
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3337
        __ call(RuntimeAddress(copyfunc_addr));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3338
        __ addptr(rsp, 6*wordSize);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3339
#else
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3340
        __ load_klass(c_rarg4, dst);
13952
e3cf184080bc 8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents: 13886
diff changeset
  3341
        __ movptr(c_rarg4, Address(c_rarg4, ObjArrayKlass::element_klass_offset()));
11430
718fc06da49a 7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents: 10565
diff changeset
  3342
        __ movl(c_rarg3, Address(c_rarg4, Klass::super_check_offset_offset()));
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3343
        __ call(RuntimeAddress(copyfunc_addr));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3344
#endif
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3345
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3346
#endif
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3347
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3348
#ifndef PRODUCT
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3349
        if (PrintC1Statistics) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3350
          Label failed;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3351
          __ testl(rax, rax);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3352
          __ jcc(Assembler::notZero, failed);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3353
          __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_cnt));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3354
          __ bind(failed);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3355
        }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3356
#endif
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3357
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3358
        __ testl(rax, rax);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3359
        __ jcc(Assembler::zero, *stub->continuation());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3360
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3361
#ifndef PRODUCT
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3362
        if (PrintC1Statistics) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3363
          __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_attempt_cnt));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3364
        }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3365
#endif
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3366
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3367
        __ mov(tmp, rax);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3368
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3369
        __ xorl(tmp, -1);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3370
9962
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3371
        // Restore previously spilled arguments
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3372
        __ movptr   (dst,     Address(rsp, 0*BytesPerWord));
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3373
        __ movptr   (dst_pos, Address(rsp, 1*BytesPerWord));
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3374
        __ movptr   (length,  Address(rsp, 2*BytesPerWord));
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3375
        __ movptr   (src_pos, Address(rsp, 3*BytesPerWord));
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3376
        __ movptr   (src,     Address(rsp, 4*BytesPerWord));
8d04042c0547 7047491: C1: registers saved incorrectly when calling checkcast_arraycopy stub
iveresov
parents: 9958
diff changeset
  3377
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3378
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3379
        __ subl(length, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3380
        __ addl(src_pos, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3381
        __ addl(dst_pos, tmp);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3382
      }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3383
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3384
      __ jmp(*stub->entry());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3385
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3386
      __ bind(cont);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3387
      __ pop(dst);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3388
      __ pop(src);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3389
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3390
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3391
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3392
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3393
  if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3394
    // Sanity check the known type with the incoming class.  For the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3395
    // primitive case the types must match exactly with src.klass and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3396
    // dst.klass each exactly matching the default type.  For the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3397
    // object array case, if no type check is needed then either the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3398
    // dst type is exactly the expected type and the src type is a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3399
    // subtype which we can't check or src is the same array as dst
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3400
    // but not necessarily exactly of type default_type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3401
    Label known_ok, halt;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  3402
    __ mov_metadata(tmp, default_type->constant_encoding());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3403
#ifdef _LP64
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  3404
    if (UseCompressedClassPointers) {
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13886
diff changeset
  3405
      __ encode_klass_not_null(tmp);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3406
    }
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3407
#endif
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3408
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3409
    if (basic_type != T_OBJECT) {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3410
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  3411
      if (UseCompressedClassPointers)          __ cmpl(tmp, dst_klass_addr);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3412
      else                   __ cmpptr(tmp, dst_klass_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3413
      __ jcc(Assembler::notEqual, halt);
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  3414
      if (UseCompressedClassPointers)          __ cmpl(tmp, src_klass_addr);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3415
      else                   __ cmpptr(tmp, src_klass_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3416
      __ jcc(Assembler::equal, known_ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3417
    } else {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19710
diff changeset
  3418
      if (UseCompressedClassPointers)          __ cmpl(tmp, dst_klass_addr);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3419
      else                   __ cmpptr(tmp, dst_klass_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3420
      __ jcc(Assembler::equal, known_ok);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3421
      __ cmpptr(src, dst);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3422
      __ jcc(Assembler::equal, known_ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3423
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3424
    __ bind(halt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3425
    __ stop("incorrect type information in arraycopy");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3426
    __ bind(known_ok);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3427
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3428
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3429
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3430
#ifndef PRODUCT
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3431
  if (PrintC1Statistics) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3432
    __ incrementl(ExternalAddress(Runtime1::arraycopy_count_address(basic_type)));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3433
  }
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3434
#endif
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3435
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3436
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3437
  assert_different_registers(c_rarg0, dst, dst_pos, length);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3438
  __ lea(c_rarg0, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3439
  assert_different_registers(c_rarg1, length);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3440
  __ lea(c_rarg1, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3441
  __ mov(c_rarg2, length);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3442
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3443
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3444
  __ lea(tmp, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3445
  store_parameter(tmp, 0);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3446
  __ lea(tmp, Address(dst, dst_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3447
  store_parameter(tmp, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3448
  store_parameter(length, 2);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3449
#endif // _LP64
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3450
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3451
  bool disjoint = (flags & LIR_OpArrayCopy::overlapping) == 0;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3452
  bool aligned = (flags & LIR_OpArrayCopy::unaligned) == 0;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3453
  const char *name;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3454
  address entry = StubRoutines::select_arraycopy_function(basic_type, aligned, disjoint, name, false);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8882
diff changeset
  3455
  __ call_VM_leaf(entry, 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3456
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3457
  __ bind(*stub->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3458
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3459
18507
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3460
void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3461
  assert(op->crc()->is_single_cpu(),  "crc must be register");
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3462
  assert(op->val()->is_single_cpu(),  "byte value must be register");
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3463
  assert(op->result_opr()->is_single_cpu(), "result must be register");
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3464
  Register crc = op->crc()->as_register();
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3465
  Register val = op->val()->as_register();
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3466
  Register res = op->result_opr()->as_register();
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3467
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3468
  assert_different_registers(val, crc, res);
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3469
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3470
  __ lea(res, ExternalAddress(StubRoutines::crc_table_addr()));
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3471
  __ notl(crc); // ~crc
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3472
  __ update_byte_crc32(crc, val, res);
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3473
  __ notl(crc); // ~crc
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3474
  __ mov(res, crc);
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 16611
diff changeset
  3475
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3476
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3477
void LIR_Assembler::emit_lock(LIR_OpLock* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3478
  Register obj = op->obj_opr()->as_register();  // may not be an oop
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3479
  Register hdr = op->hdr_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3480
  Register lock = op->lock_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3481
  if (!UseFastLocking) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3482
    __ jmp(*op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3483
  } else if (op->code() == lir_lock) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3484
    Register scratch = noreg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3485
    if (UseBiasedLocking) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3486
      scratch = op->scratch_opr()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3487
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3488
    assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
51469
8a9e5819eab5 8209668: Explicit barriers for C1/assembler
rkennke
parents: 50577
diff changeset
  3489
    __ resolve(ACCESS_READ | ACCESS_WRITE, obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3490
    // add debug info for NullPointerException only if one is possible
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3491
    int null_check_offset = __ lock_object(hdr, obj, lock, scratch, *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3492
    if (op->info() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3493
      add_debug_info_for_null_check(null_check_offset, op->info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3494
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3495
    // done
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3496
  } else if (op->code() == lir_unlock) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3497
    assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3498
    __ unlock_object(hdr, obj, lock, *op->stub()->entry());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3499
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3500
    Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3501
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3502
  __ bind(*op->stub()->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3503
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3504
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3505
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3506
void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3507
  ciMethod* method = op->profiled_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3508
  int bci          = op->profiled_bci();
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  3509
  ciMethod* callee = op->profiled_callee();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3510
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3511
  // Update counter for all call types
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  3512
  ciMethodData* md = method->method_data_or_null();
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  3513
  assert(md != NULL, "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3514
  ciProfileData* data = md->bci_to_data(bci);
48856
c866eaca24cb 8194984: 9 Null pointer dereference defect groups related to ciMethodData::bci_to_data()
dlong
parents: 48807
diff changeset
  3515
  assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3516
  assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3517
  Register mdo  = op->mdo()->as_register();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  3518
  __ mov_metadata(mdo, md->constant_encoding());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3519
  Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3520
  // Perform additional virtual call profiling for invokevirtual and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3521
  // invokeinterface bytecodes
47698
d4bfafe600d0 8166750: C1 profiling handles statically bindable call sites differently than the interpreter
iveresov
parents: 47683
diff changeset
  3522
  if (op->should_profile_receiver_type()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3523
    assert(op->recv()->is_single_cpu(), "recv must be allocated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3524
    Register recv = op->recv()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3525
    assert_different_registers(mdo, recv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3526
    assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3527
    ciKlass* known_klass = op->known_holder();
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3528
    if (C1OptimizeVirtualCallProfiling && known_klass != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3529
      // We know the type that will be seen at this call site; we can
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  3530
      // statically update the MethodData* rather than needing to do
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3531
      // dynamic tests on the receiver type
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3532
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3533
      // NOTE: we should probably put a lock around this search to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3534
      // avoid collisions by concurrent compilations
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3535
      ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3536
      uint i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3537
      for (i = 0; i < VirtualCallData::row_limit(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3538
        ciKlass* receiver = vc_data->receiver(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3539
        if (known_klass->equals(receiver)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3540
          Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3541
          __ addptr(data_addr, DataLayout::counter_increment);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3542
          return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3543
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3544
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3545
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3546
      // Receiver type not found in profile data; select an empty slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3547
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3548
      // Note that this is less efficient than it should be because it
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3549
      // always does a write to the receiver part of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3550
      // VirtualCallData rather than just the first time
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3551
      for (i = 0; i < VirtualCallData::row_limit(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3552
        ciKlass* receiver = vc_data->receiver(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3553
        if (receiver == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3554
          Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)));
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
  3555
          __ mov_metadata(recv_addr, known_klass->constant_encoding());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3556
          Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3557
          __ addptr(data_addr, DataLayout::counter_increment);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3558
          return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3559
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3560
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3561
    } else {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  3562
      __ load_klass(recv, recv);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3563
      Label update_done;
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3564
      type_profile_helper(mdo, md, data, recv, &update_done);
4754
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4752
diff changeset
  3565
      // Receiver did not match any saved receiver and there is no empty row for it.
4892
e977b527544a 6923002: assert(false,"this call site should not be polymorphic")
kvn
parents: 4754
diff changeset
  3566
      // Increment total counter to indicate polymorphic case.
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3567
      __ addptr(counter_addr, DataLayout::counter_increment);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3568
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3569
      __ bind(update_done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3570
    }
4754
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4752
diff changeset
  3571
  } else {
8aef16f24e16 6614597: Performance variability in jvm2008 xml.validation
kvn
parents: 4752
diff changeset
  3572
    // Static call
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5702
diff changeset
  3573
    __ addptr(counter_addr, DataLayout::counter_increment);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3574
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3575
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3576
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3577
void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3578
  Register obj = op->obj()->as_register();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3579
  Register tmp = op->tmp()->as_pointer_register();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3580
  Address mdo_addr = as_Address(op->mdp()->as_address_ptr());
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3581
  ciKlass* exact_klass = op->exact_klass();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3582
  intptr_t current_klass = op->current_klass();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3583
  bool not_null = op->not_null();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3584
  bool no_conflict = op->no_conflict();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3585
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3586
  Label update, next, none;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3587
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3588
  bool do_null = !not_null;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3589
  bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3590
  bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3591
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3592
  assert(do_null || do_update, "why are we here?");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3593
  assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3594
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3595
  __ verify_oop(obj);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3596
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3597
  if (tmp != obj) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3598
    __ mov(tmp, obj);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3599
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3600
  if (do_null) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3601
    __ testptr(tmp, tmp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3602
    __ jccb(Assembler::notZero, update);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3603
    if (!TypeEntries::was_null_seen(current_klass)) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3604
      __ orptr(mdo_addr, TypeEntries::null_seen);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3605
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3606
    if (do_update) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3607
#ifndef ASSERT
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3608
      __ jmpb(next);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3609
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3610
#else
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3611
      __ jmp(next);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3612
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3613
  } else {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3614
    __ testptr(tmp, tmp);
51633
21154cb84d2a 8209594: guarantee(this->is8bit(imm8)) failed: Short forward jump exceeds 8-bit offset
kvn
parents: 51469
diff changeset
  3615
    __ jcc(Assembler::notZero, update);
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3616
    __ stop("unexpect null obj");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3617
#endif
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3618
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3619
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3620
  __ bind(update);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3621
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3622
  if (do_update) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3623
#ifdef ASSERT
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3624
    if (exact_klass != NULL) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3625
      Label ok;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3626
      __ load_klass(tmp, tmp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3627
      __ push(tmp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3628
      __ mov_metadata(tmp, exact_klass->constant_encoding());
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3629
      __ cmpptr(tmp, Address(rsp, 0));
51633
21154cb84d2a 8209594: guarantee(this->is8bit(imm8)) failed: Short forward jump exceeds 8-bit offset
kvn
parents: 51469
diff changeset
  3630
      __ jcc(Assembler::equal, ok);
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3631
      __ stop("exact klass and actual klass differ");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3632
      __ bind(ok);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3633
      __ pop(tmp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3634
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3635
#endif
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3636
    if (!no_conflict) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3637
      if (exact_klass == NULL || TypeEntries::is_type_none(current_klass)) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3638
        if (exact_klass != NULL) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3639
          __ mov_metadata(tmp, exact_klass->constant_encoding());
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3640
        } else {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3641
          __ load_klass(tmp, tmp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3642
        }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3643
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3644
        __ xorptr(tmp, mdo_addr);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3645
        __ testptr(tmp, TypeEntries::type_klass_mask);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3646
        // klass seen before, nothing to do. The unknown bit may have been
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3647
        // set already but no need to check.
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3648
        __ jccb(Assembler::zero, next);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3649
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3650
        __ testptr(tmp, TypeEntries::type_unknown);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3651
        __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3652
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3653
        if (TypeEntries::is_type_none(current_klass)) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3654
          __ cmpptr(mdo_addr, 0);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3655
          __ jccb(Assembler::equal, none);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3656
          __ cmpptr(mdo_addr, TypeEntries::null_seen);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3657
          __ jccb(Assembler::equal, none);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3658
          // There is a chance that the checks above (re-reading profiling
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3659
          // data from memory) fail if another thread has just set the
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3660
          // profiling to this obj's klass
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3661
          __ xorptr(tmp, mdo_addr);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3662
          __ testptr(tmp, TypeEntries::type_klass_mask);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3663
          __ jccb(Assembler::zero, next);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3664
        }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3665
      } else {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3666
        assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3667
               ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3668
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3669
        __ movptr(tmp, mdo_addr);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3670
        __ testptr(tmp, TypeEntries::type_unknown);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3671
        __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3672
      }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3673
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3674
      // different than before. Cannot keep accurate profile.
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3675
      __ orptr(mdo_addr, TypeEntries::type_unknown);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3676
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3677
      if (TypeEntries::is_type_none(current_klass)) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3678
        __ jmpb(next);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3679
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3680
        __ bind(none);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3681
        // first time here. Set profile type.
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3682
        __ movptr(mdo_addr, tmp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3683
      }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3684
    } else {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3685
      // There's a single possible klass at this profile point
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3686
      assert(exact_klass != NULL, "should be");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3687
      if (TypeEntries::is_type_none(current_klass)) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3688
        __ mov_metadata(tmp, exact_klass->constant_encoding());
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3689
        __ xorptr(tmp, mdo_addr);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3690
        __ testptr(tmp, TypeEntries::type_klass_mask);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3691
#ifdef ASSERT
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3692
        __ jcc(Assembler::zero, next);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3693
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3694
        {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3695
          Label ok;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3696
          __ push(tmp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3697
          __ cmpptr(mdo_addr, 0);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3698
          __ jcc(Assembler::equal, ok);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3699
          __ cmpptr(mdo_addr, TypeEntries::null_seen);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3700
          __ jcc(Assembler::equal, ok);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3701
          // may have been set by another thread
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3702
          __ mov_metadata(tmp, exact_klass->constant_encoding());
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3703
          __ xorptr(tmp, mdo_addr);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3704
          __ testptr(tmp, TypeEntries::type_mask);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3705
          __ jcc(Assembler::zero, ok);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3706
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3707
          __ stop("unexpected profiling mismatch");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3708
          __ bind(ok);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3709
          __ pop(tmp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3710
        }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3711
#else
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3712
        __ jccb(Assembler::zero, next);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3713
#endif
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3714
        // first time here. Set profile type.
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3715
        __ movptr(mdo_addr, tmp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3716
      } else {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3717
        assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3718
               ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3719
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3720
        __ movptr(tmp, mdo_addr);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3721
        __ testptr(tmp, TypeEntries::type_unknown);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3722
        __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3723
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3724
        __ orptr(mdo_addr, TypeEntries::type_unknown);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3725
      }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3726
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3727
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3728
    __ bind(next);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3729
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3730
}
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20022
diff changeset
  3731
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3732
void LIR_Assembler::emit_delay(LIR_OpDelay*) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3733
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3734
}
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 LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3738
  __ lea(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3739
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3740
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3741
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3742
void LIR_Assembler::align_backward_branch_target() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3743
  __ align(BytesPerWord);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3744
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3745
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3746
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3747
void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest, LIR_Opr tmp) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3748
  if (left->is_single_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3749
    __ negl(left->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3750
    move_regs(left->as_register(), dest->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3751
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3752
  } else if (left->is_double_cpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3753
    Register lo = left->as_register_lo();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3754
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3755
    Register dst = dest->as_register_lo();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3756
    __ movptr(dst, lo);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3757
    __ negptr(dst);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3758
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3759
    Register hi = left->as_register_hi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3760
    __ lneg(hi, lo);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3761
    if (dest->as_register_lo() == hi) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3762
      assert(dest->as_register_hi() != lo, "destroying register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3763
      move_regs(hi, dest->as_register_hi());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3764
      move_regs(lo, dest->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3765
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3766
      move_regs(lo, dest->as_register_lo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3767
      move_regs(hi, dest->as_register_hi());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3768
    }
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3769
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3770
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3771
  } else if (dest->is_single_xmm()) {
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3772
#ifdef _LP64
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3773
    if (UseAVX > 2 && !VM_Version::supports_avx512vl()) {
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3774
      assert(tmp->is_valid(), "need temporary");
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3775
      assert_different_registers(left->as_xmm_float_reg(), tmp->as_xmm_float_reg());
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3776
      __ vpxor(dest->as_xmm_float_reg(), tmp->as_xmm_float_reg(), left->as_xmm_float_reg(), 2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3777
    }
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3778
    else
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3779
#endif
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3780
    {
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3781
      assert(!tmp->is_valid(), "do not need temporary");
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3782
      if (left->as_xmm_float_reg() != dest->as_xmm_float_reg()) {
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3783
        __ movflt(dest->as_xmm_float_reg(), left->as_xmm_float_reg());
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3784
      }
32727
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32203
diff changeset
  3785
      __ xorps(dest->as_xmm_float_reg(),
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32203
diff changeset
  3786
               ExternalAddress((address)float_signflip_pool));
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32203
diff changeset
  3787
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3788
  } else if (dest->is_double_xmm()) {
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3789
#ifdef _LP64
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3790
    if (UseAVX > 2 && !VM_Version::supports_avx512vl()) {
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3791
      assert(tmp->is_valid(), "need temporary");
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3792
      assert_different_registers(left->as_xmm_double_reg(), tmp->as_xmm_double_reg());
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3793
      __ vpxor(dest->as_xmm_double_reg(), tmp->as_xmm_double_reg(), left->as_xmm_double_reg(), 2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3794
    }
51857
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3795
    else
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3796
#endif
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3797
    {
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3798
      assert(!tmp->is_valid(), "do not need temporary");
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3799
      if (left->as_xmm_double_reg() != dest->as_xmm_double_reg()) {
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3800
        __ movdbl(dest->as_xmm_double_reg(), left->as_xmm_double_reg());
9978fea8a371 8210764: Update avx512 implementation
kvn
parents: 51756
diff changeset
  3801
      }
32727
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32203
diff changeset
  3802
      __ xorpd(dest->as_xmm_double_reg(),
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32203
diff changeset
  3803
               ExternalAddress((address)double_signflip_pool));
320855c2baef 8132160: support for AVX 512 call frames and stack management
mcberg
parents: 32203
diff changeset
  3804
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3805
  } else if (left->is_single_fpu() || left->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3806
    assert(left->fpu() == 0, "arg must be on TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3807
    assert(dest->fpu() == 0, "dest must be TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3808
    __ fchs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3809
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3810
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3811
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3812
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3813
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3814
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3815
50102
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3816
void LIR_Assembler::leal(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3817
  assert(src->is_address(), "must be an address");
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3818
  assert(dest->is_register(), "must be a register");
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3819
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3820
  PatchingStub* patch = NULL;
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3821
  if (patch_code != lir_patch_none) {
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3822
    patch = new PatchingStub(_masm, PatchingStub::access_field_id);
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3823
  }
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3824
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3825
  Register reg = dest->as_pointer_register();
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3826
  LIR_Address* addr = src->as_address_ptr();
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3827
  __ lea(reg, as_Address(addr));
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3828
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3829
  if (patch != NULL) {
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3830
    patching_epilog(patch, patch_code, addr->base()->as_register(), info);
454fa295105c 8202976: Add C1 lea patching support for x86
pliden
parents: 49480
diff changeset
  3831
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3832
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3833
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3834
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3835
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3836
void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3837
  assert(!tmp->is_valid(), "don't need temporary");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3838
  __ call(RuntimeAddress(dest));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3839
  if (info != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3840
    add_call_info_here(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3841
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3842
}
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 LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3846
  assert(type == T_LONG, "only for volatile long fields");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3847
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3848
  if (info != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3849
    add_debug_info_for_null_check_here(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3850
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3851
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3852
  if (src->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3853
    if (dest->is_double_cpu()) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3854
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3855
      __ movdq(dest->as_register_lo(), src->as_xmm_double_reg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3856
#else
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3857
      __ movdl(dest->as_register_lo(), src->as_xmm_double_reg());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3858
      __ psrlq(src->as_xmm_double_reg(), 32);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3859
      __ movdl(dest->as_register_hi(), src->as_xmm_double_reg());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3860
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3861
    } else if (dest->is_double_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3862
      __ movdbl(frame_map()->address_for_slot(dest->double_stack_ix()), src->as_xmm_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3863
    } else if (dest->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3864
      __ movdbl(as_Address(dest->as_address_ptr()), src->as_xmm_double_reg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3865
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3866
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3867
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3868
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3869
  } else if (dest->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3870
    if (src->is_double_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3871
      __ movdbl(dest->as_xmm_double_reg(), frame_map()->address_for_slot(src->double_stack_ix()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3872
    } else if (src->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3873
      __ movdbl(dest->as_xmm_double_reg(), as_Address(src->as_address_ptr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3874
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3875
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3876
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3877
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3878
  } else if (src->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3879
    assert(src->fpu_regnrLo() == 0, "must be TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3880
    if (dest->is_double_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3881
      __ fistp_d(frame_map()->address_for_slot(dest->double_stack_ix()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3882
    } else if (dest->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3883
      __ fistp_d(as_Address(dest->as_address_ptr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3884
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3885
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3886
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3887
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3888
  } else if (dest->is_double_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3889
    assert(dest->fpu_regnrLo() == 0, "must be TOS");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3890
    if (src->is_double_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3891
      __ fild_d(frame_map()->address_for_slot(src->double_stack_ix()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3892
    } else if (src->is_address()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3893
      __ fild_d(as_Address(src->as_address_ptr()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3894
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3895
      ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3896
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3897
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3898
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3899
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3900
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3901
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3902
#ifdef ASSERT
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3903
// emit run-time assertion
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3904
void LIR_Assembler::emit_assert(LIR_OpAssert* op) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3905
  assert(op->code() == lir_assert, "must be");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3906
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3907
  if (op->in_opr1()->is_valid()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3908
    assert(op->in_opr2()->is_valid(), "both operands must be valid");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3909
    comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3910
  } else {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3911
    assert(op->in_opr2()->is_illegal(), "both operands must be illegal");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3912
    assert(op->condition() == lir_cond_always, "no other conditions allowed");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3913
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3914
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3915
  Label ok;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3916
  if (op->condition() != lir_cond_always) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3917
    Assembler::Condition acond = Assembler::zero;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3918
    switch (op->condition()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3919
      case lir_cond_equal:        acond = Assembler::equal;       break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3920
      case lir_cond_notEqual:     acond = Assembler::notEqual;    break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3921
      case lir_cond_less:         acond = Assembler::less;        break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3922
      case lir_cond_lessEqual:    acond = Assembler::lessEqual;   break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3923
      case lir_cond_greaterEqual: acond = Assembler::greaterEqual;break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3924
      case lir_cond_greater:      acond = Assembler::greater;     break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3925
      case lir_cond_belowEqual:   acond = Assembler::belowEqual;  break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3926
      case lir_cond_aboveEqual:   acond = Assembler::aboveEqual;  break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3927
      default:                    ShouldNotReachHere();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3928
    }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3929
    __ jcc(acond, ok);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3930
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3931
  if (op->halt()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3932
    const char* str = __ code_string(op->msg());
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3933
    __ stop(str);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3934
  } else {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3935
    breakpoint();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3936
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3937
  __ bind(ok);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3938
}
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14626
diff changeset
  3939
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3940
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3941
void LIR_Assembler::membar() {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3942
  // QQQ sparc TSO uses this,
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3943
  __ membar( Assembler::Membar_mask_bits(Assembler::StoreLoad));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3944
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3945
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3946
void LIR_Assembler::membar_acquire() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3947
  // No x86 machines currently require load fences
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3948
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3949
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3950
void LIR_Assembler::membar_release() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3951
  // No x86 machines currently require store fences
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3952
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3953
11886
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3954
void LIR_Assembler::membar_loadload() {
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3955
  // no-op
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3956
  //__ membar(Assembler::Membar_mask_bits(Assembler::loadload));
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3957
}
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3958
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3959
void LIR_Assembler::membar_storestore() {
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3960
  // no-op
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3961
  //__ membar(Assembler::Membar_mask_bits(Assembler::storestore));
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3962
}
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3963
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3964
void LIR_Assembler::membar_loadstore() {
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3965
  // no-op
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3966
  //__ membar(Assembler::Membar_mask_bits(Assembler::loadstore));
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3967
}
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3968
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3969
void LIR_Assembler::membar_storeload() {
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3970
  __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3971
}
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11488
diff changeset
  3972
38017
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35540
diff changeset
  3973
void LIR_Assembler::on_spin_wait() {
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35540
diff changeset
  3974
  __ pause ();
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35540
diff changeset
  3975
}
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35540
diff changeset
  3976
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3977
void LIR_Assembler::get_thread(LIR_Opr result_reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3978
  assert(result_reg->is_register(), "check");
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3979
#ifdef _LP64
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3980
  // __ get_thread(result_reg->as_register_lo());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3981
  __ mov(result_reg->as_register(), r15_thread);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3982
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3983
  __ get_thread(result_reg->as_register());
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 670
diff changeset
  3984
#endif // _LP64
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3985
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3986
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3987
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3988
void LIR_Assembler::peephole(LIR_List*) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3989
  // do nothing for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3990
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3991
13886
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3992
void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr dest, LIR_Opr tmp) {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3993
  assert(data == dest, "xchg/xadd uses only 2 operands");
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3994
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3995
  if (data->type() == T_INT) {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3996
    if (code == lir_xadd) {
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  3997
      __ lock();
13886
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3998
      __ xaddl(as_Address(src->as_address_ptr()), data->as_register());
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  3999
    } else {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4000
      __ xchgl(data->as_register(), as_Address(src->as_address_ptr()));
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4001
    }
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4002
  } else if (data->is_oop()) {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4003
    assert (code == lir_xchg, "xadd for oops");
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4004
    Register obj = data->as_register();
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4005
#ifdef _LP64
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4006
    if (UseCompressedOops) {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4007
      __ encode_heap_oop(obj);
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4008
      __ xchgl(obj, as_Address(src->as_address_ptr()));
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4009
      __ decode_heap_oop(obj);
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4010
    } else {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4011
      __ xchgptr(obj, as_Address(src->as_address_ptr()));
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4012
    }
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4013
#else
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4014
    __ xchgl(obj, as_Address(src->as_address_ptr()));
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4015
#endif
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4016
  } else if (data->type() == T_LONG) {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4017
#ifdef _LP64
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4018
    assert(data->as_register_lo() == data->as_register_hi(), "should be a single register");
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4019
    if (code == lir_xadd) {
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51952
diff changeset
  4020
      __ lock();
13886
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4021
      __ xaddq(as_Address(src->as_address_ptr()), data->as_register_lo());
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4022
    } else {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4023
      __ xchgq(data->as_register_lo(), as_Address(src->as_address_ptr()));
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4024
    }
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4025
#else
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4026
    ShouldNotReachHere();
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4027
#endif
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4028
  } else {
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4029
    ShouldNotReachHere();
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4030
  }
8d82c4dfa722 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents: 13742
diff changeset
  4031
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4032
489c9b5090e2 Initial load
duke
parents:
diff changeset
  4033
#undef __