hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp
author fyang
Sat, 05 Mar 2016 22:22:37 +0800
changeset 36565 8e38f7594806
parent 36562 4d1e93624d6a
child 37269 5c2c4e5bb067
permissions -rw-r--r--
8151340: aarch64: prefetch the destination word for write prior to ldxr/stxr loops. Summary: aarch64: add prefetch for write prior to ldxr/stxr loops. Reviewed-by: aph Contributed-by: felix.yang@linaro.org
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29454
diff changeset
     2
 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     3
 * Copyright (c) 2014, Red Hat Inc. All rights reserved.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     5
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     8
 * published by the Free Software Foundation.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
     9
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    14
 * accompanied this code).
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    15
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    19
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    22
 * questions.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    23
 *
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    24
 */
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    25
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    26
#include "precompiled.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    27
#include "asm/assembler.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    28
#include "c1/c1_CodeStubs.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    29
#include "c1/c1_Compilation.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    30
#include "c1/c1_LIRAssembler.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    31
#include "c1/c1_MacroAssembler.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    32
#include "c1/c1_Runtime1.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    33
#include "c1/c1_ValueStack.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    34
#include "ci/ciArrayKlass.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    35
#include "ci/ciInstance.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29454
diff changeset
    36
#include "gc/shared/barrierSet.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29454
diff changeset
    37
#include "gc/shared/cardTableModRefBS.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29454
diff changeset
    38
#include "gc/shared/collectedHeap.hpp"
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    39
#include "nativeInst_aarch64.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    40
#include "oops/objArrayKlass.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    41
#include "runtime/sharedRuntime.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    42
#include "vmreg_aarch64.inline.hpp"
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    43
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    44
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    45
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    46
#ifndef PRODUCT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    47
#define COMMENT(x)   do { __ block_comment(x); } while (0)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    48
#else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    49
#define COMMENT(x)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    50
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    51
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    52
NEEDS_CLEANUP // remove this definitions ?
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    53
const Register IC_Klass    = rscratch2;   // where the IC klass is cached
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    54
const Register SYNC_header = r0;   // synchronization header
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    55
const Register SHIFT_count = r0;   // where count for shift operations must be
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    56
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    57
#define __ _masm->
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    58
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    59
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    60
static void select_different_registers(Register preserve,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    61
                                       Register extra,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    62
                                       Register &tmp1,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    63
                                       Register &tmp2) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    64
  if (tmp1 == preserve) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    65
    assert_different_registers(tmp1, tmp2, extra);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    66
    tmp1 = extra;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    67
  } else if (tmp2 == preserve) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    68
    assert_different_registers(tmp1, tmp2, extra);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    69
    tmp2 = extra;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    70
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    71
  assert_different_registers(preserve, tmp1, tmp2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    72
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    73
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    74
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    75
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    76
static void select_different_registers(Register preserve,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    77
                                       Register extra,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    78
                                       Register &tmp1,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    79
                                       Register &tmp2,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    80
                                       Register &tmp3) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    81
  if (tmp1 == preserve) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    82
    assert_different_registers(tmp1, tmp2, tmp3, extra);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    83
    tmp1 = extra;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    84
  } else if (tmp2 == preserve) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    85
    assert_different_registers(tmp1, tmp2, tmp3, extra);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    86
    tmp2 = extra;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    87
  } else if (tmp3 == preserve) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    88
    assert_different_registers(tmp1, tmp2, tmp3, extra);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    89
    tmp3 = extra;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    90
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    91
  assert_different_registers(preserve, tmp1, tmp2, tmp3);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    92
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    93
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    94
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    95
bool LIR_Assembler::is_small_constant(LIR_Opr opr) { Unimplemented(); return false; }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    96
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    97
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    98
LIR_Opr LIR_Assembler::receiverOpr() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
    99
  return FrameMap::receiver_opr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   100
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   101
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   102
LIR_Opr LIR_Assembler::osrBufferPointer() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   103
  return FrameMap::as_pointer_opr(receiverOpr()->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   104
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   105
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   106
//--------------fpu register translations-----------------------
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   107
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   108
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   109
address LIR_Assembler::float_constant(float f) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   110
  address const_addr = __ float_constant(f);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   111
  if (const_addr == NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   112
    bailout("const section overflow");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   113
    return __ code()->consts()->start();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   114
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   115
    return const_addr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   116
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   117
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   118
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   119
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   120
address LIR_Assembler::double_constant(double d) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   121
  address const_addr = __ double_constant(d);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   122
  if (const_addr == NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   123
    bailout("const section overflow");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   124
    return __ code()->consts()->start();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   125
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   126
    return const_addr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   127
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   128
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   129
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   130
address LIR_Assembler::int_constant(jlong n) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   131
  address const_addr = __ long_constant(n);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   132
  if (const_addr == NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   133
    bailout("const section overflow");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   134
    return __ code()->consts()->start();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   135
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   136
    return const_addr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   137
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   138
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   139
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   140
void LIR_Assembler::set_24bit_FPU() { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   141
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   142
void LIR_Assembler::reset_FPU() { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   143
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   144
void LIR_Assembler::fpop() { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   145
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   146
void LIR_Assembler::fxch(int i) { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   147
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   148
void LIR_Assembler::fld(int i) { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   149
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   150
void LIR_Assembler::ffree(int i) { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   151
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   152
void LIR_Assembler::breakpoint() { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   153
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   154
void LIR_Assembler::push(LIR_Opr opr) { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   155
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   156
void LIR_Assembler::pop(LIR_Opr opr) { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   157
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   158
bool LIR_Assembler::is_literal_address(LIR_Address* addr) { Unimplemented(); return false; }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   159
//-------------------------------------------
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   160
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   161
static Register as_reg(LIR_Opr op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   162
  return op->is_double_cpu() ? op->as_register_lo() : op->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   163
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   164
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   165
static jlong as_long(LIR_Opr data) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   166
  jlong result;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   167
  switch (data->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   168
  case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   169
    result = (data->as_jint());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   170
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   171
  case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   172
    result = (data->as_jlong());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   173
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   174
  default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   175
    ShouldNotReachHere();
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
   176
    result = 0;  // unreachable
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   177
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   178
  return result;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   179
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   180
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   181
Address LIR_Assembler::as_Address(LIR_Address* addr, Register tmp) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   182
  Register base = addr->base()->as_pointer_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   183
  LIR_Opr opr = addr->index();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   184
  if (opr->is_cpu_register()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   185
    Register index;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   186
    if (opr->is_single_cpu())
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   187
      index = opr->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   188
    else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   189
      index = opr->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   190
    assert(addr->disp() == 0, "must be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   191
    switch(opr->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   192
      case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   193
        return Address(base, index, Address::sxtw(addr->scale()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   194
      case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   195
        return Address(base, index, Address::lsl(addr->scale()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   196
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   197
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   198
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   199
  } else  {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   200
    intptr_t addr_offset = intptr_t(addr->disp());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   201
    if (Address::offset_ok_for_immed(addr_offset, addr->scale()))
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   202
      return Address(base, addr_offset, Address::lsl(addr->scale()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   203
    else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   204
      __ mov(tmp, addr_offset);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   205
      return Address(base, tmp, Address::lsl(addr->scale()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   206
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   207
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   208
  return Address();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   209
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   210
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   211
Address LIR_Assembler::as_Address_hi(LIR_Address* addr) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   212
  ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   213
  return Address();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   214
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   215
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   216
Address LIR_Assembler::as_Address(LIR_Address* addr) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   217
  return as_Address(addr, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   218
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   219
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   220
Address LIR_Assembler::as_Address_lo(LIR_Address* addr) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   221
  return as_Address(addr, rscratch1);  // Ouch
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   222
  // FIXME: This needs to be much more clever.  See x86.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   223
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   224
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   225
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   226
void LIR_Assembler::osr_entry() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   227
  offsets()->set_value(CodeOffsets::OSR_Entry, code_offset());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   228
  BlockBegin* osr_entry = compilation()->hir()->osr_entry();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   229
  ValueStack* entry_state = osr_entry->state();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   230
  int number_of_locks = entry_state->locks_size();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   231
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   232
  // we jump here if osr happens with the interpreter
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   233
  // state set up to continue at the beginning of the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   234
  // loop that triggered osr - in particular, we have
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   235
  // the following registers setup:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   236
  //
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   237
  // r2: osr buffer
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   238
  //
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   239
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   240
  // build frame
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   241
  ciMethod* m = compilation()->method();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   242
  __ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   243
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   244
  // OSR buffer is
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   245
  //
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   246
  // locals[nlocals-1..0]
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   247
  // monitors[0..number_of_locks]
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   248
  //
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   249
  // locals is a direct copy of the interpreter frame so in the osr buffer
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   250
  // so first slot in the local array is the last local from the interpreter
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   251
  // and last slot is local[0] (receiver) from the interpreter
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   252
  //
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   253
  // Similarly with locks. The first lock slot in the osr buffer is the nth lock
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   254
  // from the interpreter frame, the nth lock slot in the osr buffer is 0th lock
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   255
  // in the interpreter frame (the method lock if a sync method)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   256
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   257
  // Initialize monitors in the compiled activation.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   258
  //   r2: pointer to osr buffer
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   259
  //
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   260
  // All other registers are dead at this point and the locals will be
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   261
  // copied into place by code emitted in the IR.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   262
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   263
  Register OSR_buf = osrBufferPointer()->as_pointer_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   264
  { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   265
    int monitor_offset = BytesPerWord * method()->max_locals() +
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   266
      (2 * BytesPerWord) * (number_of_locks - 1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   267
    // SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   268
    // the OSR buffer using 2 word entries: first the lock and then
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   269
    // the oop.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   270
    for (int i = 0; i < number_of_locks; i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   271
      int slot_offset = monitor_offset - ((i * 2) * BytesPerWord);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   272
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   273
      // verify the interpreter's monitor has a non-null object
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   274
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   275
        Label L;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   276
        __ ldr(rscratch1, Address(OSR_buf, slot_offset + 1*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   277
        __ cbnz(rscratch1, L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   278
        __ stop("locked object is NULL");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   279
        __ bind(L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   280
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   281
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   282
      __ ldr(r19, Address(OSR_buf, slot_offset + 0));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   283
      __ str(r19, frame_map()->address_for_monitor_lock(i));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   284
      __ ldr(r19, Address(OSR_buf, slot_offset + 1*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   285
      __ str(r19, frame_map()->address_for_monitor_object(i));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   286
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   287
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   288
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   289
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   290
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   291
// inline cache check; done before the frame is built.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   292
int LIR_Assembler::check_icache() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   293
  Register receiver = FrameMap::receiver_opr->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   294
  Register ic_klass = IC_Klass;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   295
  int start_offset = __ offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   296
  __ inline_cache_check(receiver, ic_klass);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   297
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   298
  // if icache check fails, then jump to runtime routine
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   299
  // Note: RECEIVER must still contain the receiver!
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   300
  Label dont;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   301
  __ br(Assembler::EQ, dont);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   302
  __ far_jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   303
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   304
  // We align the verified entry point unless the method body
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   305
  // (including its inline cache check) will fit in a single 64-byte
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   306
  // icache line.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   307
  if (! method()->is_accessor() || __ offset() - start_offset > 4 * 4) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   308
    // force alignment after the cache check.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   309
    __ align(CodeEntryAlignment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   310
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   311
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   312
  __ bind(dont);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   313
  return start_offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   314
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   315
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   316
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   317
void LIR_Assembler::jobject2reg(jobject o, Register reg) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   318
  if (o == NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   319
    __ mov(reg, zr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   320
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   321
    __ movoop(reg, o, /*immediate*/true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   322
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   323
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   324
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   325
void LIR_Assembler::deoptimize_trap(CodeEmitInfo *info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   326
  address target = NULL;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   327
  relocInfo::relocType reloc_type = relocInfo::none;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   328
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   329
  switch (patching_id(info)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   330
  case PatchingStub::access_field_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   331
    target = Runtime1::entry_for(Runtime1::access_field_patching_id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   332
    reloc_type = relocInfo::section_word_type;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   333
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   334
  case PatchingStub::load_klass_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   335
    target = Runtime1::entry_for(Runtime1::load_klass_patching_id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   336
    reloc_type = relocInfo::metadata_type;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   337
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   338
  case PatchingStub::load_mirror_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   339
    target = Runtime1::entry_for(Runtime1::load_mirror_patching_id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   340
    reloc_type = relocInfo::oop_type;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   341
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   342
  case PatchingStub::load_appendix_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   343
    target = Runtime1::entry_for(Runtime1::load_appendix_patching_id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   344
    reloc_type = relocInfo::oop_type;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   345
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   346
  default: ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   347
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   348
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   349
  __ far_call(RuntimeAddress(target));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   350
  add_call_info_here(info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   351
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   352
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   353
void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo *info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   354
  deoptimize_trap(info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   355
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   356
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   357
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   358
// This specifies the rsp decrement needed to build the frame
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   359
int LIR_Assembler::initial_frame_size_in_bytes() const {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   360
  // if rounding, must let FrameMap know!
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   361
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   362
  // The frame_map records size in slots (32bit word)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   363
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   364
  // subtract two words to account for return address and link
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   365
  return (frame_map()->framesize() - (2*VMRegImpl::slots_per_word))  * VMRegImpl::stack_slot_size;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   366
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   367
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   368
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   369
int LIR_Assembler::emit_exception_handler() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   370
  // if the last instruction is a call (typically to do a throw which
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   371
  // is coming at the end after block reordering) the return address
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   372
  // must still point into the code area in order to avoid assertion
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   373
  // failures when searching for the corresponding bci => add a nop
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   374
  // (was bug 5/14/1999 - gri)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   375
  __ nop();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   376
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   377
  // generate code for exception handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   378
  address handler_base = __ start_a_stub(exception_handler_size);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   379
  if (handler_base == NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   380
    // not enough space left for the handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   381
    bailout("exception handler overflow");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   382
    return -1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   383
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   384
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   385
  int offset = code_offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   386
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   387
  // the exception oop and pc are in r0, and r3
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   388
  // no other registers need to be preserved, so invalidate them
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   389
  __ invalidate_registers(false, true, true, false, true, true);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   390
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   391
  // check that there is really an exception
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   392
  __ verify_not_null_oop(r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   393
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   394
  // search an exception handler (r0: exception oop, r3: throwing pc)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   395
  __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::handle_exception_from_callee_id)));  __ should_not_reach_here();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   396
  guarantee(code_offset() - offset <= exception_handler_size, "overflow");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   397
  __ end_a_stub();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   398
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   399
  return offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   400
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   401
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   402
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   403
// Emit the code to remove the frame from the stack in the exception
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   404
// unwind path.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   405
int LIR_Assembler::emit_unwind_handler() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   406
#ifndef PRODUCT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   407
  if (CommentedAssembly) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   408
    _masm->block_comment("Unwind handler");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   409
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   410
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   411
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   412
  int offset = code_offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   413
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   414
  // Fetch the exception from TLS and clear out exception related thread state
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   415
  __ ldr(r0, Address(rthread, JavaThread::exception_oop_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   416
  __ str(zr, Address(rthread, JavaThread::exception_oop_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   417
  __ str(zr, Address(rthread, JavaThread::exception_pc_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   418
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   419
  __ bind(_unwind_handler_entry);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   420
  __ verify_not_null_oop(r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   421
  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   422
    __ mov(r19, r0);  // Preserve the exception
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   423
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   424
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   425
  // Preform needed unlocking
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   426
  MonitorExitStub* stub = NULL;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   427
  if (method()->is_synchronized()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   428
    monitor_address(0, FrameMap::r0_opr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   429
    stub = new MonitorExitStub(FrameMap::r0_opr, true, 0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   430
    __ unlock_object(r5, r4, r0, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   431
    __ bind(*stub->continuation());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   432
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   433
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   434
  if (compilation()->env()->dtrace_method_probes()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   435
    __ call_Unimplemented();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   436
#if 0
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   437
    __ movptr(Address(rsp, 0), rax);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   438
    __ mov_metadata(Address(rsp, sizeof(void*)), method()->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   439
    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   440
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   441
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   442
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   443
  if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   444
    __ mov(r0, r19);  // Restore the exception
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   445
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   446
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   447
  // remove the activation and dispatch to the unwind handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   448
  __ block_comment("remove_frame and dispatch to the unwind handler");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   449
  __ remove_frame(initial_frame_size_in_bytes());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   450
  __ far_jump(RuntimeAddress(Runtime1::entry_for(Runtime1::unwind_exception_id)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   451
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   452
  // Emit the slow path assembly
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   453
  if (stub != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   454
    stub->emit_code(this);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   455
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   456
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   457
  return offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   458
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   459
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   460
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   461
int LIR_Assembler::emit_deopt_handler() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   462
  // if the last instruction is a call (typically to do a throw which
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   463
  // is coming at the end after block reordering) the return address
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   464
  // must still point into the code area in order to avoid assertion
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   465
  // failures when searching for the corresponding bci => add a nop
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   466
  // (was bug 5/14/1999 - gri)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   467
  __ nop();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   468
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   469
  // generate code for exception handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   470
  address handler_base = __ start_a_stub(deopt_handler_size);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   471
  if (handler_base == NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   472
    // not enough space left for the handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   473
    bailout("deopt handler overflow");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   474
    return -1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   475
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   476
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   477
  int offset = code_offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   478
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   479
  __ adr(lr, pc());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   480
  __ far_jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   481
  guarantee(code_offset() - offset <= deopt_handler_size, "overflow");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   482
  __ end_a_stub();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   483
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   484
  return offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   485
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   486
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   487
void LIR_Assembler::add_debug_info_for_branch(address adr, CodeEmitInfo* info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   488
  _masm->code_section()->relocate(adr, relocInfo::poll_type);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   489
  int pc_offset = code_offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   490
  flush_debug_info(pc_offset);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   491
  info->record_debug_info(compilation()->debug_info_recorder(), pc_offset);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   492
  if (info->exception_handlers() != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   493
    compilation()->add_exception_handlers_for_pco(pc_offset, info->exception_handlers());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   494
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   495
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   496
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   497
// Rather than take a segfault when the polling page is protected,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   498
// explicitly check for a safepoint in progress and if there is one,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   499
// fake a call to the handler as if a segfault had been caught.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   500
void LIR_Assembler::poll_for_safepoint(relocInfo::relocType rtype, CodeEmitInfo* info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   501
  __ mov(rscratch1, SafepointSynchronize::address_of_state());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   502
  __ ldrb(rscratch1, Address(rscratch1));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   503
  Label nope, poll;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   504
  __ cbz(rscratch1, nope);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   505
  __ block_comment("safepoint");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   506
  __ enter();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   507
  __ push(0x3, sp);                // r0 & r1
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   508
  __ push(0x3ffffffc, sp);         // integer registers except lr & sp & r0 & r1
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   509
  __ adr(r0, poll);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   510
  __ str(r0, Address(rthread, JavaThread::saved_exception_pc_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   511
  __ mov(rscratch1, CAST_FROM_FN_PTR(address, SharedRuntime::get_poll_stub));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   512
  __ blrt(rscratch1, 1, 0, 1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   513
  __ maybe_isb();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   514
  __ pop(0x3ffffffc, sp);          // integer registers except lr & sp & r0 & r1
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   515
  __ mov(rscratch1, r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   516
  __ pop(0x3, sp);                 // r0 & r1
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   517
  __ leave();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   518
  __ br(rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   519
  address polling_page(os::get_polling_page());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   520
  assert(os::is_poll_address(polling_page), "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   521
  unsigned long off;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   522
  __ adrp(rscratch1, Address(polling_page, rtype), off);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   523
  __ bind(poll);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   524
  if (info)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   525
    add_debug_info_for_branch(info);  // This isn't just debug info:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   526
                                      // it's the oop map
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   527
  else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   528
    __ code_section()->relocate(pc(), rtype);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   529
  __ ldrw(zr, Address(rscratch1, off));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   530
  __ bind(nope);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   531
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   532
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   533
void LIR_Assembler::return_op(LIR_Opr result) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   534
  assert(result->is_illegal() || !result->is_single_cpu() || result->as_register() == r0, "word returns are in r0,");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   535
  // Pop the stack before the safepoint code
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   536
  __ remove_frame(initial_frame_size_in_bytes());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   537
  address polling_page(os::get_polling_page());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   538
  __ read_polling_page(rscratch1, polling_page, relocInfo::poll_return_type);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   539
  __ ret(lr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   540
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   541
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   542
int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   543
  address polling_page(os::get_polling_page());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   544
  guarantee(info != NULL, "Shouldn't be NULL");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   545
  assert(os::is_poll_address(polling_page), "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   546
  unsigned long off;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   547
  __ adrp(rscratch1, Address(polling_page, relocInfo::poll_type), off);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   548
  assert(off == 0, "must be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   549
  add_debug_info_for_branch(info);  // This isn't just debug info:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   550
  // it's the oop map
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   551
  __ read_polling_page(rscratch1, relocInfo::poll_type);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   552
  return __ offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   553
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   554
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   555
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   556
void LIR_Assembler::move_regs(Register from_reg, Register to_reg) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   557
  if (from_reg == r31_sp)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   558
    from_reg = sp;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   559
  if (to_reg == r31_sp)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   560
    to_reg = sp;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   561
  __ mov(to_reg, from_reg);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   562
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   563
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   564
void LIR_Assembler::swap_reg(Register a, Register b) { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   565
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   566
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   567
void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   568
  assert(src->is_constant(), "should not call otherwise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   569
  assert(dest->is_register(), "should not call otherwise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   570
  LIR_Const* c = src->as_constant_ptr();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   571
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   572
  switch (c->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   573
    case T_INT: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   574
      assert(patch_code == lir_patch_none, "no patching handled here");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   575
      __ movw(dest->as_register(), c->as_jint());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   576
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   577
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   578
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   579
    case T_ADDRESS: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   580
      assert(patch_code == lir_patch_none, "no patching handled here");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   581
      __ mov(dest->as_register(), c->as_jint());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   582
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   583
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   584
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   585
    case T_LONG: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   586
      assert(patch_code == lir_patch_none, "no patching handled here");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   587
      __ mov(dest->as_register_lo(), (intptr_t)c->as_jlong());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   588
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   589
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   590
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   591
    case T_OBJECT: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   592
        if (patch_code == lir_patch_none) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   593
          jobject2reg(c->as_jobject(), dest->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   594
        } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   595
          jobject2reg_with_patching(dest->as_register(), info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   596
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   597
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   598
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   599
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   600
    case T_METADATA: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   601
      if (patch_code != lir_patch_none) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   602
        klass2reg_with_patching(dest->as_register(), info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   603
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   604
        __ mov_metadata(dest->as_register(), c->as_metadata());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   605
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   606
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   607
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   608
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   609
    case T_FLOAT: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   610
      if (__ operand_valid_for_float_immediate(c->as_jfloat())) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   611
        __ fmovs(dest->as_float_reg(), (c->as_jfloat()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   612
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   613
        __ adr(rscratch1, InternalAddress(float_constant(c->as_jfloat())));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   614
        __ ldrs(dest->as_float_reg(), Address(rscratch1));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   615
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   616
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   617
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   618
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   619
    case T_DOUBLE: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   620
      if (__ operand_valid_for_float_immediate(c->as_jdouble())) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   621
        __ fmovd(dest->as_double_reg(), (c->as_jdouble()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   622
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   623
        __ adr(rscratch1, InternalAddress(double_constant(c->as_jdouble())));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   624
        __ ldrd(dest->as_double_reg(), Address(rscratch1));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   625
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   626
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   627
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   628
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   629
    default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   630
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   631
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   632
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   633
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   634
void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   635
  LIR_Const* c = src->as_constant_ptr();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   636
  switch (c->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   637
  case T_OBJECT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   638
    {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   639
      if (! c->as_jobject())
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   640
        __ str(zr, frame_map()->address_for_slot(dest->single_stack_ix()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   641
      else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   642
        const2reg(src, FrameMap::rscratch1_opr, lir_patch_none, NULL);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   643
        reg2stack(FrameMap::rscratch1_opr, dest, c->type(), false);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   644
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   645
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   646
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   647
  case T_ADDRESS:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   648
    {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   649
      const2reg(src, FrameMap::rscratch1_opr, lir_patch_none, NULL);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   650
      reg2stack(FrameMap::rscratch1_opr, dest, c->type(), false);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   651
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   652
  case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   653
  case T_FLOAT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   654
    {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   655
      Register reg = zr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   656
      if (c->as_jint_bits() == 0)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   657
        __ strw(zr, frame_map()->address_for_slot(dest->single_stack_ix()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   658
      else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   659
        __ movw(rscratch1, c->as_jint_bits());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   660
        __ strw(rscratch1, frame_map()->address_for_slot(dest->single_stack_ix()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   661
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   662
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   663
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   664
  case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   665
  case T_DOUBLE:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   666
    {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   667
      Register reg = zr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   668
      if (c->as_jlong_bits() == 0)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   669
        __ str(zr, frame_map()->address_for_slot(dest->double_stack_ix(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   670
                                                 lo_word_offset_in_bytes));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   671
      else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   672
        __ mov(rscratch1, (intptr_t)c->as_jlong_bits());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   673
        __ str(rscratch1, frame_map()->address_for_slot(dest->double_stack_ix(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   674
                                                        lo_word_offset_in_bytes));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   675
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   676
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   677
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   678
  default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   679
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   680
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   681
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   682
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   683
void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info, bool wide) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   684
  assert(src->is_constant(), "should not call otherwise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   685
  LIR_Const* c = src->as_constant_ptr();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   686
  LIR_Address* to_addr = dest->as_address_ptr();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   687
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   688
  void (Assembler::* insn)(Register Rt, const Address &adr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   689
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   690
  switch (type) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   691
  case T_ADDRESS:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   692
    assert(c->as_jint() == 0, "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   693
    insn = &Assembler::str;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   694
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   695
  case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   696
    assert(c->as_jlong() == 0, "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   697
    insn = &Assembler::str;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   698
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   699
  case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   700
    assert(c->as_jint() == 0, "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   701
    insn = &Assembler::strw;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   702
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   703
  case T_OBJECT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   704
  case T_ARRAY:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   705
    assert(c->as_jobject() == 0, "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   706
    if (UseCompressedOops && !wide) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   707
      insn = &Assembler::strw;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   708
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   709
      insn = &Assembler::str;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   710
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   711
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   712
  case T_CHAR:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   713
  case T_SHORT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   714
    assert(c->as_jint() == 0, "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   715
    insn = &Assembler::strh;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   716
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   717
  case T_BOOLEAN:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   718
  case T_BYTE:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   719
    assert(c->as_jint() == 0, "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   720
    insn = &Assembler::strb;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   721
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   722
  default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   723
    ShouldNotReachHere();
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
   724
    insn = &Assembler::str;  // unreachable
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   725
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   726
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   727
  if (info) add_debug_info_for_null_check_here(info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   728
  (_masm->*insn)(zr, as_Address(to_addr, rscratch1));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   729
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   730
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   731
void LIR_Assembler::reg2reg(LIR_Opr src, LIR_Opr dest) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   732
  assert(src->is_register(), "should not call otherwise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   733
  assert(dest->is_register(), "should not call otherwise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   734
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   735
  // move between cpu-registers
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   736
  if (dest->is_single_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   737
    if (src->type() == T_LONG) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   738
      // Can do LONG -> OBJECT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   739
      move_regs(src->as_register_lo(), dest->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   740
      return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   741
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   742
    assert(src->is_single_cpu(), "must match");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   743
    if (src->type() == T_OBJECT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   744
      __ verify_oop(src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   745
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   746
    move_regs(src->as_register(), dest->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   747
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   748
  } else if (dest->is_double_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   749
    if (src->type() == T_OBJECT || src->type() == T_ARRAY) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   750
      // Surprising to me but we can see move of a long to t_object
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   751
      __ verify_oop(src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   752
      move_regs(src->as_register(), dest->as_register_lo());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   753
      return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   754
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   755
    assert(src->is_double_cpu(), "must match");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   756
    Register f_lo = src->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   757
    Register f_hi = src->as_register_hi();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   758
    Register t_lo = dest->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   759
    Register t_hi = dest->as_register_hi();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   760
    assert(f_hi == f_lo, "must be same");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   761
    assert(t_hi == t_lo, "must be same");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   762
    move_regs(f_lo, t_lo);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   763
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   764
  } else if (dest->is_single_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   765
    __ fmovs(dest->as_float_reg(), src->as_float_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   766
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   767
  } else if (dest->is_double_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   768
    __ fmovd(dest->as_double_reg(), src->as_double_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   769
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   770
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   771
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   772
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   773
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   774
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   775
void LIR_Assembler::reg2stack(LIR_Opr src, LIR_Opr dest, BasicType type, bool pop_fpu_stack) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   776
  if (src->is_single_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   777
    if (type == T_ARRAY || type == T_OBJECT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   778
      __ str(src->as_register(), frame_map()->address_for_slot(dest->single_stack_ix()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   779
      __ verify_oop(src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   780
    } else if (type == T_METADATA || type == T_DOUBLE) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   781
      __ str(src->as_register(), frame_map()->address_for_slot(dest->single_stack_ix()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   782
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   783
      __ strw(src->as_register(), frame_map()->address_for_slot(dest->single_stack_ix()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   784
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   785
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   786
  } else if (src->is_double_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   787
    Address dest_addr_LO = frame_map()->address_for_slot(dest->double_stack_ix(), lo_word_offset_in_bytes);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   788
    __ str(src->as_register_lo(), dest_addr_LO);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   789
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   790
  } else if (src->is_single_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   791
    Address dest_addr = frame_map()->address_for_slot(dest->single_stack_ix());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   792
    __ strs(src->as_float_reg(), dest_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   793
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   794
  } else if (src->is_double_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   795
    Address dest_addr = frame_map()->address_for_slot(dest->double_stack_ix());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   796
    __ strd(src->as_double_reg(), dest_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   797
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   798
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   799
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   800
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   801
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   802
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   803
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   804
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   805
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 */) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   806
  LIR_Address* to_addr = dest->as_address_ptr();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   807
  PatchingStub* patch = NULL;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   808
  Register compressed_src = rscratch1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   809
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   810
  if (patch_code != lir_patch_none) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   811
    deoptimize_trap(info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   812
    return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   813
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   814
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   815
  if (type == T_ARRAY || type == T_OBJECT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   816
    __ verify_oop(src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   817
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   818
    if (UseCompressedOops && !wide) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   819
      __ encode_heap_oop(compressed_src, src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   820
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   821
      compressed_src = src->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   822
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   823
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   824
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   825
  int null_check_here = code_offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   826
  switch (type) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   827
    case T_FLOAT: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   828
      __ strs(src->as_float_reg(), as_Address(to_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   829
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   830
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   831
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   832
    case T_DOUBLE: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   833
      __ strd(src->as_double_reg(), as_Address(to_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   834
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   835
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   836
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   837
    case T_ARRAY:   // fall through
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   838
    case T_OBJECT:  // fall through
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   839
      if (UseCompressedOops && !wide) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   840
        __ strw(compressed_src, as_Address(to_addr, rscratch2));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   841
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   842
         __ str(compressed_src, as_Address(to_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   843
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   844
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   845
    case T_METADATA:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   846
      // We get here to store a method pointer to the stack to pass to
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   847
      // a dtrace runtime call. This can't work on 64 bit with
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   848
      // compressed klass ptrs: T_METADATA can be a compressed klass
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   849
      // ptr or a 64 bit method pointer.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   850
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   851
      __ str(src->as_register(), as_Address(to_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   852
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   853
    case T_ADDRESS:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   854
      __ str(src->as_register(), as_Address(to_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   855
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   856
    case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   857
      __ strw(src->as_register(), as_Address(to_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   858
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   859
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   860
    case T_LONG: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   861
      __ str(src->as_register_lo(), as_Address_lo(to_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   862
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   863
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   864
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   865
    case T_BYTE:    // fall through
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   866
    case T_BOOLEAN: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   867
      __ strb(src->as_register(), as_Address(to_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   868
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   869
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   870
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   871
    case T_CHAR:    // fall through
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   872
    case T_SHORT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   873
      __ strh(src->as_register(), as_Address(to_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   874
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   875
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   876
    default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   877
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   878
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   879
  if (info != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   880
    add_debug_info_for_null_check(null_check_here, info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   881
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   882
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   883
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   884
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   885
void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   886
  assert(src->is_stack(), "should not call otherwise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   887
  assert(dest->is_register(), "should not call otherwise");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   888
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   889
  if (dest->is_single_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   890
    if (type == T_ARRAY || type == T_OBJECT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   891
      __ ldr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   892
      __ verify_oop(dest->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   893
    } else if (type == T_METADATA) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   894
      __ ldr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   895
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   896
      __ ldrw(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   897
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   898
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   899
  } else if (dest->is_double_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   900
    Address src_addr_LO = frame_map()->address_for_slot(src->double_stack_ix(), lo_word_offset_in_bytes);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   901
    __ ldr(dest->as_register_lo(), src_addr_LO);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   902
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   903
  } else if (dest->is_single_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   904
    Address src_addr = frame_map()->address_for_slot(src->single_stack_ix());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   905
    __ ldrs(dest->as_float_reg(), src_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   906
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   907
  } else if (dest->is_double_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   908
    Address src_addr = frame_map()->address_for_slot(src->double_stack_ix());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   909
    __ ldrd(dest->as_double_reg(), src_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   910
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   911
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   912
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   913
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   914
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   915
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   916
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   917
void LIR_Assembler::klass2reg_with_patching(Register reg, CodeEmitInfo* info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   918
  address target = NULL;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   919
  relocInfo::relocType reloc_type = relocInfo::none;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   920
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   921
  switch (patching_id(info)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   922
  case PatchingStub::access_field_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   923
    target = Runtime1::entry_for(Runtime1::access_field_patching_id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   924
    reloc_type = relocInfo::section_word_type;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   925
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   926
  case PatchingStub::load_klass_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   927
    target = Runtime1::entry_for(Runtime1::load_klass_patching_id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   928
    reloc_type = relocInfo::metadata_type;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   929
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   930
  case PatchingStub::load_mirror_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   931
    target = Runtime1::entry_for(Runtime1::load_mirror_patching_id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   932
    reloc_type = relocInfo::oop_type;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   933
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   934
  case PatchingStub::load_appendix_id:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   935
    target = Runtime1::entry_for(Runtime1::load_appendix_patching_id);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   936
    reloc_type = relocInfo::oop_type;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   937
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   938
  default: ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   939
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   940
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   941
  __ far_call(RuntimeAddress(target));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   942
  add_call_info_here(info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   943
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   944
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   945
void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   946
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   947
  LIR_Opr temp;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   948
  if (type == T_LONG || type == T_DOUBLE)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   949
    temp = FrameMap::rscratch1_long_opr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   950
  else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   951
    temp = FrameMap::rscratch1_opr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   952
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   953
  stack2reg(src, temp, src->type());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   954
  reg2stack(temp, dest, dest->type(), false);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   955
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   956
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   957
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   958
void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool wide, bool /* unaligned */) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   959
  LIR_Address* addr = src->as_address_ptr();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   960
  LIR_Address* from_addr = src->as_address_ptr();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   961
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   962
  if (addr->base()->type() == T_OBJECT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   963
    __ verify_oop(addr->base()->as_pointer_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   964
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   965
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   966
  if (patch_code != lir_patch_none) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   967
    deoptimize_trap(info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   968
    return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   969
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   970
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   971
  if (info != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   972
    add_debug_info_for_null_check_here(info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   973
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   974
  int null_check_here = code_offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   975
  switch (type) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   976
    case T_FLOAT: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   977
      __ ldrs(dest->as_float_reg(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   978
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   979
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   980
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   981
    case T_DOUBLE: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   982
      __ ldrd(dest->as_double_reg(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   983
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   984
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   985
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   986
    case T_ARRAY:   // fall through
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   987
    case T_OBJECT:  // fall through
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   988
      if (UseCompressedOops && !wide) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   989
        __ ldrw(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   990
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   991
         __ ldr(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   992
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   993
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   994
    case T_METADATA:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   995
      // We get here to store a method pointer to the stack to pass to
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   996
      // a dtrace runtime call. This can't work on 64 bit with
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   997
      // compressed klass ptrs: T_METADATA can be a compressed klass
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   998
      // ptr or a 64 bit method pointer.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
   999
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1000
      __ ldr(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1001
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1002
    case T_ADDRESS:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1003
      // FIXME: OMG this is a horrible kludge.  Any offset from an
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1004
      // address that matches klass_offset_in_bytes() will be loaded
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1005
      // as a word, not a long.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1006
      if (UseCompressedClassPointers && addr->disp() == oopDesc::klass_offset_in_bytes()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1007
        __ ldrw(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1008
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1009
        __ ldr(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1010
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1011
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1012
    case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1013
      __ ldrw(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1014
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1015
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1016
    case T_LONG: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1017
      __ ldr(dest->as_register_lo(), as_Address_lo(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1018
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1019
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1020
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1021
    case T_BYTE:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1022
      __ ldrsb(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1023
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1024
    case T_BOOLEAN: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1025
      __ ldrb(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1026
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1027
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1028
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1029
    case T_CHAR:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1030
      __ ldrh(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1031
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1032
    case T_SHORT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1033
      __ ldrsh(dest->as_register(), as_Address(from_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1034
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1035
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1036
    default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1037
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1038
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1039
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1040
  if (type == T_ARRAY || type == T_OBJECT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1041
    if (UseCompressedOops && !wide) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1042
      __ decode_heap_oop(dest->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1043
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1044
    __ verify_oop(dest->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1045
  } else if (type == T_ADDRESS && addr->disp() == oopDesc::klass_offset_in_bytes()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1046
    if (UseCompressedClassPointers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1047
      __ decode_klass_not_null(dest->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1048
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1049
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1050
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1051
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1052
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1053
int LIR_Assembler::array_element_size(BasicType type) const {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1054
  int elem_size = type2aelembytes(type);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1055
  return exact_log2(elem_size);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1056
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1057
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1058
void LIR_Assembler::emit_op3(LIR_Op3* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1059
  Register Rdividend = op->in_opr1()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1060
  Register Rdivisor  = op->in_opr2()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1061
  Register Rscratch  = op->in_opr3()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1062
  Register Rresult   = op->result_opr()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1063
  int divisor = -1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1064
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1065
  /*
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1066
  TODO: For some reason, using the Rscratch that gets passed in is
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1067
  not possible because the register allocator does not see the tmp reg
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1068
  as used, and assignes it the same register as Rdividend. We use rscratch1
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1069
   instead.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1070
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1071
  assert(Rdividend != Rscratch, "");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1072
  assert(Rdivisor  != Rscratch, "");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1073
  */
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1074
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1075
  if (Rdivisor == noreg && is_power_of_2(divisor)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1076
    // convert division by a power of two into some shifts and logical operations
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1077
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1078
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1079
  if (op->code() == lir_irem) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1080
    __ corrected_idivl(Rresult, Rdividend, Rdivisor, true, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1081
   } else if (op->code() == lir_idiv) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1082
    __ corrected_idivl(Rresult, Rdividend, Rdivisor, false, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1083
  } else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1084
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1085
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1086
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1087
void LIR_Assembler::emit_opBranch(LIR_OpBranch* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1088
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1089
  assert(op->block() == NULL || op->block()->label() == op->label(), "wrong label");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1090
  if (op->block() != NULL)  _branch_target_blocks.append(op->block());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1091
  if (op->ublock() != NULL) _branch_target_blocks.append(op->ublock());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1092
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1093
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1094
  if (op->cond() == lir_cond_always) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1095
    if (op->info() != NULL) add_debug_info_for_branch(op->info());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1096
    __ b(*(op->label()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1097
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1098
    Assembler::Condition acond;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1099
    if (op->code() == lir_cond_float_branch) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1100
      bool is_unordered = (op->ublock() == op->block());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1101
      // Assembler::EQ does not permit unordered branches, so we add
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1102
      // another branch here.  Likewise, Assembler::NE does not permit
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1103
      // ordered branches.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1104
      if (is_unordered && op->cond() == lir_cond_equal
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1105
          || !is_unordered && op->cond() == lir_cond_notEqual)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1106
        __ br(Assembler::VS, *(op->ublock()->label()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1107
      switch(op->cond()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1108
      case lir_cond_equal:        acond = Assembler::EQ; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1109
      case lir_cond_notEqual:     acond = Assembler::NE; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1110
      case lir_cond_less:         acond = (is_unordered ? Assembler::LT : Assembler::LO); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1111
      case lir_cond_lessEqual:    acond = (is_unordered ? Assembler::LE : Assembler::LS); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1112
      case lir_cond_greaterEqual: acond = (is_unordered ? Assembler::HS : Assembler::GE); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1113
      case lir_cond_greater:      acond = (is_unordered ? Assembler::HI : Assembler::GT); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1114
      default:                    ShouldNotReachHere();
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1115
        acond = Assembler::EQ;  // unreachable
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1116
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1117
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1118
      switch (op->cond()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1119
        case lir_cond_equal:        acond = Assembler::EQ; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1120
        case lir_cond_notEqual:     acond = Assembler::NE; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1121
        case lir_cond_less:         acond = Assembler::LT; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1122
        case lir_cond_lessEqual:    acond = Assembler::LE; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1123
        case lir_cond_greaterEqual: acond = Assembler::GE; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1124
        case lir_cond_greater:      acond = Assembler::GT; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1125
        case lir_cond_belowEqual:   acond = Assembler::LS; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1126
        case lir_cond_aboveEqual:   acond = Assembler::HS; break;
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1127
        default:                    ShouldNotReachHere();
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1128
          acond = Assembler::EQ;  // unreachable
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1129
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1130
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1131
    __ br(acond,*(op->label()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1132
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1133
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1134
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1135
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1136
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1137
void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1138
  LIR_Opr src  = op->in_opr();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1139
  LIR_Opr dest = op->result_opr();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1140
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1141
  switch (op->bytecode()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1142
    case Bytecodes::_i2f:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1143
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1144
        __ scvtfws(dest->as_float_reg(), src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1145
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1146
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1147
    case Bytecodes::_i2d:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1148
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1149
        __ scvtfwd(dest->as_double_reg(), src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1150
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1151
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1152
    case Bytecodes::_l2d:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1153
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1154
        __ scvtfd(dest->as_double_reg(), src->as_register_lo());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1155
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1156
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1157
    case Bytecodes::_l2f:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1158
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1159
        __ scvtfs(dest->as_float_reg(), src->as_register_lo());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1160
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1161
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1162
    case Bytecodes::_f2d:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1163
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1164
        __ fcvts(dest->as_double_reg(), src->as_float_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1165
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1166
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1167
    case Bytecodes::_d2f:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1168
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1169
        __ fcvtd(dest->as_float_reg(), src->as_double_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1170
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1171
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1172
    case Bytecodes::_i2c:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1173
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1174
        __ ubfx(dest->as_register(), src->as_register(), 0, 16);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1175
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1176
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1177
    case Bytecodes::_i2l:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1178
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1179
        __ sxtw(dest->as_register_lo(), src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1180
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1181
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1182
    case Bytecodes::_i2s:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1183
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1184
        __ sxth(dest->as_register(), src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1185
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1186
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1187
    case Bytecodes::_i2b:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1188
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1189
        __ sxtb(dest->as_register(), src->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1190
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1191
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1192
    case Bytecodes::_l2i:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1193
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1194
        _masm->block_comment("FIXME: This could be a no-op");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1195
        __ uxtw(dest->as_register(), src->as_register_lo());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1196
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1197
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1198
    case Bytecodes::_d2l:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1199
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1200
        __ fcvtzd(dest->as_register_lo(), src->as_double_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1201
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1202
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1203
    case Bytecodes::_f2i:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1204
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1205
        __ fcvtzsw(dest->as_register(), src->as_float_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1206
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1207
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1208
    case Bytecodes::_f2l:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1209
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1210
        __ fcvtzs(dest->as_register_lo(), src->as_float_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1211
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1212
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1213
    case Bytecodes::_d2i:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1214
      {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1215
        __ fcvtzdw(dest->as_register(), src->as_double_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1216
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1217
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1218
    default: ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1219
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1220
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1221
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1222
void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1223
  if (op->init_check()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1224
    __ ldrb(rscratch1, Address(op->klass()->as_register(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1225
                               InstanceKlass::init_state_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1226
    __ cmpw(rscratch1, InstanceKlass::fully_initialized);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1227
    add_debug_info_for_null_check_here(op->stub()->info());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1228
    __ br(Assembler::NE, *op->stub()->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1229
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1230
  __ allocate_object(op->obj()->as_register(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1231
                     op->tmp1()->as_register(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1232
                     op->tmp2()->as_register(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1233
                     op->header_size(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1234
                     op->object_size(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1235
                     op->klass()->as_register(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1236
                     *op->stub()->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1237
  __ bind(*op->stub()->continuation());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1238
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1239
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1240
void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1241
  Register len =  op->len()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1242
  __ uxtw(len, len);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1243
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1244
  if (UseSlowPath ||
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1245
      (!UseFastNewObjectArray && (op->type() == T_OBJECT || op->type() == T_ARRAY)) ||
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1246
      (!UseFastNewTypeArray   && (op->type() != T_OBJECT && op->type() != T_ARRAY))) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1247
    __ b(*op->stub()->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1248
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1249
    Register tmp1 = op->tmp1()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1250
    Register tmp2 = op->tmp2()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1251
    Register tmp3 = op->tmp3()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1252
    if (len == tmp1) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1253
      tmp1 = tmp3;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1254
    } else if (len == tmp2) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1255
      tmp2 = tmp3;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1256
    } else if (len == tmp3) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1257
      // everything is ok
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1258
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1259
      __ mov(tmp3, len);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1260
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1261
    __ allocate_array(op->obj()->as_register(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1262
                      len,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1263
                      tmp1,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1264
                      tmp2,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1265
                      arrayOopDesc::header_size(op->type()),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1266
                      array_element_size(op->type()),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1267
                      op->klass()->as_register(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1268
                      *op->stub()->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1269
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1270
  __ bind(*op->stub()->continuation());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1271
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1272
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1273
void LIR_Assembler::type_profile_helper(Register mdo,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1274
                                        ciMethodData *md, ciProfileData *data,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1275
                                        Register recv, Label* update_done) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1276
  for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1277
    Label next_test;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1278
    // See if the receiver is receiver[n].
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1279
    __ lea(rscratch2, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1280
    __ ldr(rscratch1, Address(rscratch2));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1281
    __ cmp(recv, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1282
    __ br(Assembler::NE, next_test);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1283
    Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1284
    __ addptr(data_addr, DataLayout::counter_increment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1285
    __ b(*update_done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1286
    __ bind(next_test);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1287
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1288
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1289
  // Didn't find receiver; find next empty slot and fill it in
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1290
  for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1291
    Label next_test;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1292
    __ lea(rscratch2,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1293
           Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1294
    Address recv_addr(rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1295
    __ ldr(rscratch1, recv_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1296
    __ cbnz(rscratch1, next_test);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1297
    __ str(recv, recv_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1298
    __ mov(rscratch1, DataLayout::counter_increment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1299
    __ lea(rscratch2, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i))));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1300
    __ str(rscratch1, Address(rscratch2));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1301
    __ b(*update_done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1302
    __ bind(next_test);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1303
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1304
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1305
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1306
void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, Label* failure, Label* obj_is_null) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1307
  // we always need a stub for the failure case.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1308
  CodeStub* stub = op->stub();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1309
  Register obj = op->object()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1310
  Register k_RInfo = op->tmp1()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1311
  Register klass_RInfo = op->tmp2()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1312
  Register dst = op->result_opr()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1313
  ciKlass* k = op->klass();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1314
  Register Rtmp1 = noreg;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1315
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1316
  // check if it needs to be profiled
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1317
  ciMethodData* md;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1318
  ciProfileData* data;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1319
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1320
  const bool should_profile = op->should_profile();
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1321
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1322
  if (should_profile) {
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1323
    ciMethod* method = op->profiled_method();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1324
    assert(method != NULL, "Should have method");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1325
    int bci = op->profiled_bci();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1326
    md = method->method_data_or_null();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1327
    assert(md != NULL, "Sanity");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1328
    data = md->bci_to_data(bci);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1329
    assert(data != NULL,                "need data for type check");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1330
    assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1331
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1332
  Label profile_cast_success, profile_cast_failure;
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1333
  Label *success_target = should_profile ? &profile_cast_success : success;
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1334
  Label *failure_target = should_profile ? &profile_cast_failure : failure;
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1335
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1336
  if (obj == k_RInfo) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1337
    k_RInfo = dst;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1338
  } else if (obj == klass_RInfo) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1339
    klass_RInfo = dst;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1340
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1341
  if (k->is_loaded() && !UseCompressedClassPointers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1342
    select_different_registers(obj, dst, k_RInfo, klass_RInfo);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1343
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1344
    Rtmp1 = op->tmp3()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1345
    select_different_registers(obj, dst, k_RInfo, klass_RInfo, Rtmp1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1346
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1347
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1348
  assert_different_registers(obj, k_RInfo, klass_RInfo);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1349
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1350
    if (should_profile) {
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1351
      Label not_null;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1352
      __ cbnz(obj, not_null);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1353
      // Object is null; update MDO and exit
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1354
      Register mdo  = klass_RInfo;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1355
      __ mov_metadata(mdo, md->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1356
      Address data_addr
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1357
        = __ form_address(rscratch2, mdo,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1358
                          md->byte_offset_of_slot(data, DataLayout::DataLayout::header_offset()),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1359
                          LogBytesPerWord);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1360
      int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1361
      __ ldr(rscratch1, data_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1362
      __ orr(rscratch1, rscratch1, header_bits);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1363
      __ str(rscratch1, data_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1364
      __ b(*obj_is_null);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1365
      __ bind(not_null);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1366
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1367
      __ cbz(obj, *obj_is_null);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1368
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1369
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1370
  if (!k->is_loaded()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1371
    klass2reg_with_patching(k_RInfo, op->info_for_patch());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1372
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1373
    __ mov_metadata(k_RInfo, k->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1374
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1375
  __ verify_oop(obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1376
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1377
  if (op->fast_check()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1378
    // get object class
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1379
    // not a safepoint as obj null check happens earlier
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1380
    __ load_klass(rscratch1, obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1381
    __ cmp( rscratch1, k_RInfo);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1382
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1383
    __ br(Assembler::NE, *failure_target);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1384
    // successful cast, fall through to profile or jump
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1385
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1386
    // get object class
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1387
    // not a safepoint as obj null check happens earlier
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1388
    __ load_klass(klass_RInfo, obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1389
    if (k->is_loaded()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1390
      // See if we get an immediate positive hit
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1391
      __ ldr(rscratch1, Address(klass_RInfo, long(k->super_check_offset())));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1392
      __ cmp(k_RInfo, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1393
      if ((juint)in_bytes(Klass::secondary_super_cache_offset()) != k->super_check_offset()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1394
        __ br(Assembler::NE, *failure_target);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1395
        // successful cast, fall through to profile or jump
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1396
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1397
        // See if we get an immediate positive hit
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1398
        __ br(Assembler::EQ, *success_target);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1399
        // check for self
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1400
        __ cmp(klass_RInfo, k_RInfo);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1401
        __ br(Assembler::EQ, *success_target);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1402
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1403
        __ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1404
        __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1405
        __ ldr(klass_RInfo, Address(__ post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1406
        // result is a boolean
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1407
        __ cbzw(klass_RInfo, *failure_target);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1408
        // successful cast, fall through to profile or jump
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1409
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1410
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1411
      // perform the fast part of the checking logic
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1412
      __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1413
      // call out-of-line instance of __ check_klass_subtype_slow_path(...):
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1414
      __ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1415
      __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1416
      __ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1417
      // result is a boolean
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1418
      __ cbz(k_RInfo, *failure_target);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1419
      // successful cast, fall through to profile or jump
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1420
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1421
  }
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1422
  if (should_profile) {
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1423
    Register mdo  = klass_RInfo, recv = k_RInfo;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1424
    __ bind(profile_cast_success);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1425
    __ mov_metadata(mdo, md->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1426
    __ load_klass(recv, obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1427
    Label update_done;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1428
    type_profile_helper(mdo, md, data, recv, success);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1429
    __ b(*success);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1430
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1431
    __ bind(profile_cast_failure);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1432
    __ mov_metadata(mdo, md->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1433
    Address counter_addr
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1434
      = __ form_address(rscratch2, mdo,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1435
                        md->byte_offset_of_slot(data, CounterData::count_offset()),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1436
                        LogBytesPerWord);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1437
    __ ldr(rscratch1, counter_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1438
    __ sub(rscratch1, rscratch1, DataLayout::counter_increment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1439
    __ str(rscratch1, counter_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1440
    __ b(*failure);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1441
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1442
  __ b(*success);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1443
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1444
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1445
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1446
void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1447
  const bool should_profile = op->should_profile();
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1448
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1449
  LIR_Code code = op->code();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1450
  if (code == lir_store_check) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1451
    Register value = op->object()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1452
    Register array = op->array()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1453
    Register k_RInfo = op->tmp1()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1454
    Register klass_RInfo = op->tmp2()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1455
    Register Rtmp1 = op->tmp3()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1456
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1457
    CodeStub* stub = op->stub();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1458
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1459
    // check if it needs to be profiled
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1460
    ciMethodData* md;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1461
    ciProfileData* data;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1462
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1463
    if (should_profile) {
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1464
      ciMethod* method = op->profiled_method();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1465
      assert(method != NULL, "Should have method");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1466
      int bci = op->profiled_bci();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1467
      md = method->method_data_or_null();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1468
      assert(md != NULL, "Sanity");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1469
      data = md->bci_to_data(bci);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1470
      assert(data != NULL,                "need data for type check");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1471
      assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1472
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1473
    Label profile_cast_success, profile_cast_failure, done;
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1474
    Label *success_target = should_profile ? &profile_cast_success : &done;
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1475
    Label *failure_target = should_profile ? &profile_cast_failure : stub->entry();
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1476
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1477
    if (should_profile) {
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1478
      Label not_null;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1479
      __ cbnz(value, not_null);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1480
      // Object is null; update MDO and exit
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1481
      Register mdo  = klass_RInfo;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1482
      __ mov_metadata(mdo, md->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1483
      Address data_addr
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1484
        = __ form_address(rscratch2, mdo,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1485
                          md->byte_offset_of_slot(data, DataLayout::header_offset()),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1486
                          LogBytesPerInt);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1487
      int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1488
      __ ldrw(rscratch1, data_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1489
      __ orrw(rscratch1, rscratch1, header_bits);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1490
      __ strw(rscratch1, data_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1491
      __ b(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1492
      __ bind(not_null);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1493
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1494
      __ cbz(value, done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1495
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1496
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1497
    add_debug_info_for_null_check_here(op->info_for_exception());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1498
    __ load_klass(k_RInfo, array);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1499
    __ load_klass(klass_RInfo, value);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1500
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1501
    // get instance klass (it's already uncompressed)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1502
    __ ldr(k_RInfo, Address(k_RInfo, ObjArrayKlass::element_klass_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1503
    // perform the fast part of the checking logic
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1504
    __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, NULL);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1505
    // call out-of-line instance of __ check_klass_subtype_slow_path(...):
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1506
    __ stp(klass_RInfo, k_RInfo, Address(__ pre(sp, -2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1507
    __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1508
    __ ldp(k_RInfo, klass_RInfo, Address(__ post(sp, 2 * wordSize)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1509
    // result is a boolean
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1510
    __ cbzw(k_RInfo, *failure_target);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1511
    // fall through to the success case
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1512
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1513
    if (should_profile) {
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1514
      Register mdo  = klass_RInfo, recv = k_RInfo;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1515
      __ bind(profile_cast_success);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1516
      __ mov_metadata(mdo, md->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1517
      __ load_klass(recv, value);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1518
      Label update_done;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1519
      type_profile_helper(mdo, md, data, recv, &done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1520
      __ b(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1521
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1522
      __ bind(profile_cast_failure);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1523
      __ mov_metadata(mdo, md->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1524
      Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1525
      __ lea(rscratch2, counter_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1526
      __ ldr(rscratch1, Address(rscratch2));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1527
      __ sub(rscratch1, rscratch1, DataLayout::counter_increment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1528
      __ str(rscratch1, Address(rscratch2));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1529
      __ b(*stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1530
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1531
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1532
    __ bind(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1533
  } else if (code == lir_checkcast) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1534
    Register obj = op->object()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1535
    Register dst = op->result_opr()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1536
    Label success;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1537
    emit_typecheck_helper(op, &success, op->stub()->entry(), &success);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1538
    __ bind(success);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1539
    if (dst != obj) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1540
      __ mov(dst, obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1541
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1542
  } else if (code == lir_instanceof) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1543
    Register obj = op->object()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1544
    Register dst = op->result_opr()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1545
    Label success, failure, done;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1546
    emit_typecheck_helper(op, &success, &failure, &failure);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1547
    __ bind(failure);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1548
    __ mov(dst, zr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1549
    __ b(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1550
    __ bind(success);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1551
    __ mov(dst, 1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1552
    __ bind(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1553
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1554
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1555
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1556
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1557
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1558
void LIR_Assembler::casw(Register addr, Register newval, Register cmpval) {
36562
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1559
  if (UseLSE) {
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1560
    __ mov(rscratch1, cmpval);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1561
    __ casal(Assembler::word, rscratch1, newval, addr);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1562
    __ cmpw(rscratch1, cmpval);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1563
    __ cset(rscratch1, Assembler::NE);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1564
  } else {
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1565
    Label retry_load, nope;
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1566
    // flush and load exclusive from the memory location
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1567
    // and fail if it is not what we expect
36565
8e38f7594806 8151340: aarch64: prefetch the destination word for write prior to ldxr/stxr loops.
fyang
parents: 36562
diff changeset
  1568
    __ prfm(Address(addr), PSTL1STRM);
36562
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1569
    __ bind(retry_load);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1570
    __ ldaxrw(rscratch1, addr);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1571
    __ cmpw(rscratch1, cmpval);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1572
    __ cset(rscratch1, Assembler::NE);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1573
    __ br(Assembler::NE, nope);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1574
    // if we store+flush with no intervening write rscratch1 wil be zero
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1575
    __ stlxrw(rscratch1, newval, addr);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1576
    // retry so we only ever return after a load fails to compare
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1577
    // ensures we don't return a stale value after a failed write.
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1578
    __ cbnzw(rscratch1, retry_load);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1579
    __ bind(nope);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1580
  }
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1581
  __ membar(__ AnyAny);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1582
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1583
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1584
void LIR_Assembler::casl(Register addr, Register newval, Register cmpval) {
36562
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1585
  if (UseLSE) {
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1586
    __ mov(rscratch1, cmpval);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1587
    __ casal(Assembler::xword, rscratch1, newval, addr);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1588
    __ cmp(rscratch1, cmpval);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1589
    __ cset(rscratch1, Assembler::NE);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1590
  } else {
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1591
    Label retry_load, nope;
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1592
    // flush and load exclusive from the memory location
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1593
    // and fail if it is not what we expect
36565
8e38f7594806 8151340: aarch64: prefetch the destination word for write prior to ldxr/stxr loops.
fyang
parents: 36562
diff changeset
  1594
    __ prfm(Address(addr), PSTL1STRM);
36562
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1595
    __ bind(retry_load);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1596
    __ ldaxr(rscratch1, addr);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1597
    __ cmp(rscratch1, cmpval);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1598
    __ cset(rscratch1, Assembler::NE);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1599
    __ br(Assembler::NE, nope);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1600
    // if we store+flush with no intervening write rscratch1 wil be zero
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1601
    __ stlxr(rscratch1, newval, addr);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1602
    // retry so we only ever return after a load fails to compare
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1603
    // ensures we don't return a stale value after a failed write.
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1604
    __ cbnz(rscratch1, retry_load);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1605
    __ bind(nope);
4d1e93624d6a 8150394: aarch64: add support for 8.1 LSE CAS instructions
enevill
parents: 35584
diff changeset
  1606
  }
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1607
  __ membar(__ AnyAny);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1608
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1609
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1610
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1611
void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1612
  assert(VM_Version::supports_cx8(), "wrong machine");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1613
  Register addr = as_reg(op->addr());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1614
  Register newval = as_reg(op->new_value());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1615
  Register cmpval = as_reg(op->cmp_value());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1616
  Label succeed, fail, around;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1617
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1618
  if (op->code() == lir_cas_obj) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1619
    if (UseCompressedOops) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1620
      Register t1 = op->tmp1()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1621
      assert(op->tmp1()->is_valid(), "must be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1622
      __ encode_heap_oop(t1, cmpval);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1623
      cmpval = t1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1624
      __ encode_heap_oop(rscratch2, newval);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1625
      newval = rscratch2;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1626
      casw(addr, newval, cmpval);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1627
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1628
      casl(addr, newval, cmpval);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1629
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1630
  } else if (op->code() == lir_cas_int) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1631
    casw(addr, newval, cmpval);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1632
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1633
    casl(addr, newval, cmpval);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1634
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1635
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1636
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1637
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1638
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1639
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1640
  Assembler::Condition acond, ncond;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1641
  switch (condition) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1642
  case lir_cond_equal:        acond = Assembler::EQ; ncond = Assembler::NE; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1643
  case lir_cond_notEqual:     acond = Assembler::NE; ncond = Assembler::EQ; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1644
  case lir_cond_less:         acond = Assembler::LT; ncond = Assembler::GE; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1645
  case lir_cond_lessEqual:    acond = Assembler::LE; ncond = Assembler::GT; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1646
  case lir_cond_greaterEqual: acond = Assembler::GE; ncond = Assembler::LT; break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1647
  case lir_cond_greater:      acond = Assembler::GT; ncond = Assembler::LE; break;
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1648
  case lir_cond_belowEqual:
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1649
  case lir_cond_aboveEqual:
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1650
  default:                    ShouldNotReachHere();
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1651
    acond = Assembler::EQ; ncond = Assembler::NE;  // unreachable
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1652
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1653
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1654
  assert(result->is_single_cpu() || result->is_double_cpu(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1655
         "expect single register for result");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1656
  if (opr1->is_constant() && opr2->is_constant()
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1657
      && opr1->type() == T_INT && opr2->type() == T_INT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1658
    jint val1 = opr1->as_jint();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1659
    jint val2 = opr2->as_jint();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1660
    if (val1 == 0 && val2 == 1) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1661
      __ cset(result->as_register(), ncond);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1662
      return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1663
    } else if (val1 == 1 && val2 == 0) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1664
      __ cset(result->as_register(), acond);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1665
      return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1666
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1667
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1668
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1669
  if (opr1->is_constant() && opr2->is_constant()
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1670
      && opr1->type() == T_LONG && opr2->type() == T_LONG) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1671
    jlong val1 = opr1->as_jlong();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1672
    jlong val2 = opr2->as_jlong();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1673
    if (val1 == 0 && val2 == 1) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1674
      __ cset(result->as_register_lo(), ncond);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1675
      return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1676
    } else if (val1 == 1 && val2 == 0) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1677
      __ cset(result->as_register_lo(), acond);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1678
      return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1679
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1680
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1681
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1682
  if (opr1->is_stack()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1683
    stack2reg(opr1, FrameMap::rscratch1_opr, result->type());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1684
    opr1 = FrameMap::rscratch1_opr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1685
  } else if (opr1->is_constant()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1686
    LIR_Opr tmp
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1687
      = opr1->type() == T_LONG ? FrameMap::rscratch1_long_opr : FrameMap::rscratch1_opr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1688
    const2reg(opr1, tmp, lir_patch_none, NULL);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1689
    opr1 = tmp;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1690
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1691
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1692
  if (opr2->is_stack()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1693
    stack2reg(opr2, FrameMap::rscratch2_opr, result->type());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1694
    opr2 = FrameMap::rscratch2_opr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1695
  } else if (opr2->is_constant()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1696
    LIR_Opr tmp
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1697
      = opr2->type() == T_LONG ? FrameMap::rscratch2_long_opr : FrameMap::rscratch2_opr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1698
    const2reg(opr2, tmp, lir_patch_none, NULL);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1699
    opr2 = tmp;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1700
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1701
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1702
  if (result->type() == T_LONG)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1703
    __ csel(result->as_register_lo(), opr1->as_register_lo(), opr2->as_register_lo(), acond);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1704
  else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1705
    __ csel(result->as_register(), opr1->as_register(), opr2->as_register(), acond);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1706
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1707
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1708
void LIR_Assembler::arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest, CodeEmitInfo* info, bool pop_fpu_stack) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1709
  assert(info == NULL, "should never be used, idiv/irem and ldiv/lrem not handled by this method");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1710
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1711
  if (left->is_single_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1712
    Register lreg = left->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1713
    Register dreg = as_reg(dest);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1714
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1715
    if (right->is_single_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1716
      // cpu register - cpu register
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1717
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1718
      assert(left->type() == T_INT && right->type() == T_INT && dest->type() == T_INT,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1719
             "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1720
      Register rreg = right->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1721
      switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1722
      case lir_add: __ addw (dest->as_register(), lreg, rreg); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1723
      case lir_sub: __ subw (dest->as_register(), lreg, rreg); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1724
      case lir_mul: __ mulw (dest->as_register(), lreg, rreg); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1725
      default:      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1726
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1727
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1728
    } else if (right->is_double_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1729
      Register rreg = right->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1730
      // single_cpu + double_cpu: can happen with obj+long
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1731
      assert(code == lir_add || code == lir_sub, "mismatched arithmetic op");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1732
      switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1733
      case lir_add: __ add(dreg, lreg, rreg); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1734
      case lir_sub: __ sub(dreg, lreg, rreg); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1735
      default: ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1736
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1737
    } else if (right->is_constant()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1738
      // cpu register - constant
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1739
      jlong c;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1740
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1741
      // FIXME.  This is fugly: we really need to factor all this logic.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1742
      switch(right->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1743
      case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1744
        c = right->as_constant_ptr()->as_jlong();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1745
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1746
      case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1747
      case T_ADDRESS:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1748
        c = right->as_constant_ptr()->as_jint();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1749
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1750
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1751
        ShouldNotReachHere();
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1752
        c = 0;  // unreachable
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1753
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1754
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1755
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1756
      assert(code == lir_add || code == lir_sub, "mismatched arithmetic op");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1757
      if (c == 0 && dreg == lreg) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1758
        COMMENT("effective nop elided");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1759
        return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1760
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1761
      switch(left->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1762
      case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1763
        switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1764
        case lir_add: __ addw(dreg, lreg, c); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1765
        case lir_sub: __ subw(dreg, lreg, c); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1766
        default: ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1767
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1768
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1769
      case T_OBJECT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1770
      case T_ADDRESS:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1771
        switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1772
        case lir_add: __ add(dreg, lreg, c); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1773
        case lir_sub: __ sub(dreg, lreg, c); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1774
        default: ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1775
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1776
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1777
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1778
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1779
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1780
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1781
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1782
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1783
  } else if (left->is_double_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1784
    Register lreg_lo = left->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1785
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1786
    if (right->is_double_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1787
      // cpu register - cpu register
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1788
      Register rreg_lo = right->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1789
      switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1790
      case lir_add: __ add (dest->as_register_lo(), lreg_lo, rreg_lo); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1791
      case lir_sub: __ sub (dest->as_register_lo(), lreg_lo, rreg_lo); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1792
      case lir_mul: __ mul (dest->as_register_lo(), lreg_lo, rreg_lo); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1793
      case lir_div: __ corrected_idivq(dest->as_register_lo(), lreg_lo, rreg_lo, false, rscratch1); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1794
      case lir_rem: __ corrected_idivq(dest->as_register_lo(), lreg_lo, rreg_lo, true, rscratch1); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1795
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1796
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1797
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1798
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1799
    } else if (right->is_constant()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1800
      jlong c = right->as_constant_ptr()->as_jlong_bits();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1801
      Register dreg = as_reg(dest);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1802
      assert(code == lir_add || code == lir_sub, "mismatched arithmetic op");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1803
      if (c == 0 && dreg == lreg_lo) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1804
        COMMENT("effective nop elided");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1805
        return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1806
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1807
      switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1808
        case lir_add: __ add(dreg, lreg_lo, c); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1809
        case lir_sub: __ sub(dreg, lreg_lo, c); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1810
        default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1811
          ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1812
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1813
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1814
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1815
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1816
  } else if (left->is_single_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1817
    assert(right->is_single_fpu(), "right hand side of float arithmetics needs to be float register");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1818
    switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1819
    case lir_add: __ fadds (dest->as_float_reg(), left->as_float_reg(), right->as_float_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1820
    case lir_sub: __ fsubs (dest->as_float_reg(), left->as_float_reg(), right->as_float_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1821
    case lir_mul: __ fmuls (dest->as_float_reg(), left->as_float_reg(), right->as_float_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1822
    case lir_div: __ fdivs (dest->as_float_reg(), left->as_float_reg(), right->as_float_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1823
    default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1824
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1825
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1826
  } else if (left->is_double_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1827
    if (right->is_double_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1828
      // cpu register - cpu register
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1829
      switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1830
      case lir_add: __ faddd (dest->as_double_reg(), left->as_double_reg(), right->as_double_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1831
      case lir_sub: __ fsubd (dest->as_double_reg(), left->as_double_reg(), right->as_double_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1832
      case lir_mul: __ fmuld (dest->as_double_reg(), left->as_double_reg(), right->as_double_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1833
      case lir_div: __ fdivd (dest->as_double_reg(), left->as_double_reg(), right->as_double_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1834
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1835
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1836
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1837
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1838
      if (right->is_constant()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1839
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1840
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1841
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1842
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1843
  } else if (left->is_single_stack() || left->is_address()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1844
    assert(left == dest, "left and dest must be equal");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1845
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1846
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1847
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1848
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1849
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1850
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1851
void LIR_Assembler::arith_fpu_implementation(LIR_Code code, int left_index, int right_index, int dest_index, bool pop_fpu_stack) { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1852
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1853
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1854
void LIR_Assembler::intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr unused, LIR_Opr dest, LIR_Op* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1855
  switch(code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1856
  case lir_abs : __ fabsd(dest->as_double_reg(), value->as_double_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1857
  case lir_sqrt: __ fsqrtd(dest->as_double_reg(), value->as_double_reg()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1858
  default      : ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1859
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1860
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1861
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1862
void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1863
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1864
  assert(left->is_single_cpu() || left->is_double_cpu(), "expect single or double register");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1865
  Register Rleft = left->is_single_cpu() ? left->as_register() :
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1866
                                           left->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1867
   if (dst->is_single_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1868
     Register Rdst = dst->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1869
     if (right->is_constant()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1870
       switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1871
         case lir_logic_and: __ andw (Rdst, Rleft, right->as_jint()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1872
         case lir_logic_or:  __ orrw (Rdst, Rleft, right->as_jint()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1873
         case lir_logic_xor: __ eorw (Rdst, Rleft, right->as_jint()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1874
         default: ShouldNotReachHere(); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1875
       }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1876
     } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1877
       Register Rright = right->is_single_cpu() ? right->as_register() :
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1878
                                                  right->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1879
       switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1880
         case lir_logic_and: __ andw (Rdst, Rleft, Rright); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1881
         case lir_logic_or:  __ orrw (Rdst, Rleft, Rright); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1882
         case lir_logic_xor: __ eorw (Rdst, Rleft, Rright); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1883
         default: ShouldNotReachHere(); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1884
       }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1885
     }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1886
   } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1887
     Register Rdst = dst->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1888
     if (right->is_constant()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1889
       switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1890
         case lir_logic_and: __ andr (Rdst, Rleft, right->as_jlong()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1891
         case lir_logic_or:  __ orr (Rdst, Rleft, right->as_jlong()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1892
         case lir_logic_xor: __ eor (Rdst, Rleft, right->as_jlong()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1893
         default: ShouldNotReachHere(); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1894
       }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1895
     } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1896
       Register Rright = right->is_single_cpu() ? right->as_register() :
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1897
                                                  right->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1898
       switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1899
         case lir_logic_and: __ andr (Rdst, Rleft, Rright); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1900
         case lir_logic_or:  __ orr (Rdst, Rleft, Rright); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1901
         case lir_logic_xor: __ eor (Rdst, Rleft, Rright); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1902
         default: ShouldNotReachHere(); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1903
       }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1904
     }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1905
   }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1906
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1907
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1908
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1909
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1910
void LIR_Assembler::arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr temp, LIR_Opr result, CodeEmitInfo* info) { Unimplemented(); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1911
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1912
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1913
void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1914
  if (opr1->is_constant() && opr2->is_single_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1915
    // tableswitch
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1916
    Register reg = as_reg(opr2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1917
    struct tableswitch &table = switches[opr1->as_constant_ptr()->as_jint()];
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1918
    __ tableswitch(reg, table._first_key, table._last_key, table._branches, table._after);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1919
  } else if (opr1->is_single_cpu() || opr1->is_double_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1920
    Register reg1 = as_reg(opr1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1921
    if (opr2->is_single_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1922
      // cpu register - cpu register
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1923
      Register reg2 = opr2->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1924
      if (opr1->type() == T_OBJECT || opr1->type() == T_ARRAY) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1925
        __ cmp(reg1, reg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1926
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1927
        assert(opr2->type() != T_OBJECT && opr2->type() != T_ARRAY, "cmp int, oop?");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1928
        __ cmpw(reg1, reg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1929
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1930
      return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1931
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1932
    if (opr2->is_double_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1933
      // cpu register - cpu register
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1934
      Register reg2 = opr2->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1935
      __ cmp(reg1, reg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1936
      return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1937
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1938
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1939
    if (opr2->is_constant()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1940
      jlong imm;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1941
      switch(opr2->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1942
      case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1943
        imm = opr2->as_constant_ptr()->as_jlong();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1944
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1945
      case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1946
      case T_ADDRESS:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1947
        imm = opr2->as_constant_ptr()->as_jint();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1948
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1949
      case T_OBJECT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1950
      case T_ARRAY:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1951
        imm = jlong(opr2->as_constant_ptr()->as_jobject());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1952
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1953
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1954
        ShouldNotReachHere();
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  1955
        imm = 0;  // unreachable
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1956
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1957
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1958
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1959
      if (Assembler::operand_valid_for_add_sub_immediate(imm)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1960
        if (type2aelembytes(opr1->type()) <= 4)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1961
          __ cmpw(reg1, imm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1962
        else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1963
          __ cmp(reg1, imm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1964
        return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1965
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1966
        __ mov(rscratch1, imm);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1967
        if (type2aelembytes(opr1->type()) <= 4)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1968
          __ cmpw(reg1, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1969
        else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1970
          __ cmp(reg1, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1971
        return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1972
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1973
    } else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1974
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1975
  } else if (opr1->is_single_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1976
    FloatRegister reg1 = opr1->as_float_reg();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1977
    assert(opr2->is_single_fpu(), "expect single float register");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1978
    FloatRegister reg2 = opr2->as_float_reg();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1979
    __ fcmps(reg1, reg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1980
  } else if (opr1->is_double_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1981
    FloatRegister reg1 = opr1->as_double_reg();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1982
    assert(opr2->is_double_fpu(), "expect double float register");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1983
    FloatRegister reg2 = opr2->as_double_reg();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1984
    __ fcmpd(reg1, reg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1985
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1986
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1987
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1988
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1989
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1990
void LIR_Assembler::comp_fl2i(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst, LIR_Op2* op){
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1991
  if (code == lir_cmp_fd2i || code == lir_ucmp_fd2i) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1992
    bool is_unordered_less = (code == lir_ucmp_fd2i);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1993
    if (left->is_single_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1994
      __ float_cmp(true, is_unordered_less ? -1 : 1, left->as_float_reg(), right->as_float_reg(), dst->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1995
    } else if (left->is_double_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1996
      __ float_cmp(false, is_unordered_less ? -1 : 1, left->as_double_reg(), right->as_double_reg(), dst->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1997
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1998
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  1999
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2000
  } else if (code == lir_cmp_l2i) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2001
    Label done;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2002
    __ cmp(left->as_register_lo(), right->as_register_lo());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2003
    __ mov(dst->as_register(), (u_int64_t)-1L);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2004
    __ br(Assembler::LT, done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2005
    __ csinc(dst->as_register(), zr, zr, Assembler::EQ);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2006
    __ bind(done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2007
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2008
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2009
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2010
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2011
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2012
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2013
void LIR_Assembler::align_call(LIR_Code code) {  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2014
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2015
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2016
void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) {
32082
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2017
  address call = __ trampoline_call(Address(op->addr(), rtype));
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2018
  if (call == NULL) {
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2019
    bailout("trampoline stub overflow");
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2020
    return;
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2021
  }
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2022
  add_call_info(code_offset(), op->info());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2023
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2024
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2025
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2026
void LIR_Assembler::ic_call(LIR_OpJavaCall* op) {
32082
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2027
  address call = __ ic_call(op->addr());
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2028
  if (call == NULL) {
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2029
    bailout("trampoline stub overflow");
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2030
    return;
2a3323e25de1 8130309: Need to bailout cleanly if creation of stubs fails when codecache is out of space
thartmann
parents: 30764
diff changeset
  2031
  }
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2032
  add_call_info(code_offset(), op->info());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2033
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2034
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2035
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2036
/* Currently, vtable-dispatch is only enabled for sparc platforms */
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2037
void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2038
  ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2039
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2040
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2041
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2042
void LIR_Assembler::emit_static_call_stub() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2043
  address call_pc = __ pc();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2044
  address stub = __ start_a_stub(call_stub_size);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2045
  if (stub == NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2046
    bailout("static call stub overflow");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2047
    return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2048
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2049
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2050
  int start = __ offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2051
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2052
  __ relocate(static_stub_Relocation::spec(call_pc));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2053
  __ mov_metadata(rmethod, (Metadata*)NULL);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2054
  __ movptr(rscratch1, 0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2055
  __ br(rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2056
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2057
  assert(__ offset() - start <= call_stub_size, "stub too big");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2058
  __ end_a_stub();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2059
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2060
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2061
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2062
void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2063
  assert(exceptionOop->as_register() == r0, "must match");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2064
  assert(exceptionPC->as_register() == r3, "must match");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2065
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2066
  // exception object is not added to oop map by LinearScan
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2067
  // (LinearScan assumes that no oops are in fixed registers)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2068
  info->add_register_oop(exceptionOop);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2069
  Runtime1::StubID unwind_id;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2070
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2071
  // get current pc information
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2072
  // pc is only needed if the method has an exception handler, the unwind code does not need it.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2073
  int pc_for_athrow_offset = __ offset();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2074
  InternalAddress pc_for_athrow(__ pc());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2075
  __ adr(exceptionPC->as_register(), pc_for_athrow);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2076
  add_call_info(pc_for_athrow_offset, info); // for exception handler
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2077
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2078
  __ verify_not_null_oop(r0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2079
  // search an exception handler (r0: exception oop, r3: throwing pc)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2080
  if (compilation()->has_fpu_code()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2081
    unwind_id = Runtime1::handle_exception_id;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2082
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2083
    unwind_id = Runtime1::handle_exception_nofpu_id;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2084
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2085
  __ far_call(RuntimeAddress(Runtime1::entry_for(unwind_id)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2086
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2087
  // FIXME: enough room for two byte trap   ????
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2088
  __ nop();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2089
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2090
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2091
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2092
void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2093
  assert(exceptionOop->as_register() == r0, "must match");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2094
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2095
  __ b(_unwind_handler_entry);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2096
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2097
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2098
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2099
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, LIR_Opr count, LIR_Opr dest, LIR_Opr tmp) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2100
  Register lreg = left->is_single_cpu() ? left->as_register() : left->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2101
  Register dreg = dest->is_single_cpu() ? dest->as_register() : dest->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2102
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2103
  switch (left->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2104
    case T_INT: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2105
      switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2106
      case lir_shl:  __ lslvw (dreg, lreg, count->as_register()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2107
      case lir_shr:  __ asrvw (dreg, lreg, count->as_register()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2108
      case lir_ushr: __ lsrvw (dreg, lreg, count->as_register()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2109
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2110
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2111
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2112
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2113
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2114
    case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2115
    case T_ADDRESS:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2116
    case T_OBJECT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2117
      switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2118
      case lir_shl:  __ lslv (dreg, lreg, count->as_register()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2119
      case lir_shr:  __ asrv (dreg, lreg, count->as_register()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2120
      case lir_ushr: __ lsrv (dreg, lreg, count->as_register()); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2121
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2122
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2123
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2124
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2125
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2126
    default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2127
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2128
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2129
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2130
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2131
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2132
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2133
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2134
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr dest) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2135
  Register dreg = dest->is_single_cpu() ? dest->as_register() : dest->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2136
  Register lreg = left->is_single_cpu() ? left->as_register() : left->as_register_lo();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2137
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2138
  switch (left->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2139
    case T_INT: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2140
      switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2141
      case lir_shl:  __ lslw (dreg, lreg, count); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2142
      case lir_shr:  __ asrw (dreg, lreg, count); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2143
      case lir_ushr: __ lsrw (dreg, lreg, count); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2144
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2145
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2146
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2147
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2148
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2149
    case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2150
    case T_ADDRESS:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2151
    case T_OBJECT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2152
      switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2153
      case lir_shl:  __ lsl (dreg, lreg, count); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2154
      case lir_shr:  __ asr (dreg, lreg, count); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2155
      case lir_ushr: __ lsr (dreg, lreg, count); break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2156
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2157
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2158
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2159
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2160
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2161
    default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2162
      ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2163
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2164
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2165
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2166
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2167
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2168
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2169
void LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2170
  assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2171
  int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2172
  assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2173
  __ str (r, Address(sp, offset_from_rsp_in_bytes));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2174
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2175
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2176
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2177
void LIR_Assembler::store_parameter(jint c,     int offset_from_rsp_in_words) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2178
  assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2179
  int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2180
  assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2181
  __ mov (rscratch1, c);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2182
  __ str (rscratch1, Address(sp, offset_from_rsp_in_bytes));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2183
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2185
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2186
void LIR_Assembler::store_parameter(jobject o,  int offset_from_rsp_in_words) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2187
  ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2188
  assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2189
  int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2190
  assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2191
  __ lea(rscratch1, __ constant_oop_address(o));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2192
  __ str(rscratch1, Address(sp, offset_from_rsp_in_bytes));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2193
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2194
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2195
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2196
// This code replaces a call to arraycopy; no exception may
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2197
// be thrown in this code, they must be thrown in the System.arraycopy
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2198
// activation frame; we could save some checks if this would not be the case
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2199
void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2200
  ciArrayKlass* default_type = op->expected_type();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2201
  Register src = op->src()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2202
  Register dst = op->dst()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2203
  Register src_pos = op->src_pos()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2204
  Register dst_pos = op->dst_pos()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2205
  Register length  = op->length()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2206
  Register tmp = op->tmp()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2207
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2208
  CodeStub* stub = op->stub();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2209
  int flags = op->flags();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2210
  BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2211
  if (basic_type == T_ARRAY) basic_type = T_OBJECT;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2212
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2213
  // if we don't know anything, just go through the generic arraycopy
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2214
  if (default_type == NULL // || basic_type == T_OBJECT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2215
      ) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2216
    Label done;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2217
    assert(src == r1 && src_pos == r2, "mismatch in calling convention");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2218
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2219
    // Save the arguments in case the generic arraycopy fails and we
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2220
    // have to fall back to the JNI stub
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2221
    __ stp(dst,     dst_pos, Address(sp, 0*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2222
    __ stp(length,  src_pos, Address(sp, 2*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2223
    __ str(src,              Address(sp, 4*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2224
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2225
    address C_entry = CAST_FROM_FN_PTR(address, Runtime1::arraycopy);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2226
    address copyfunc_addr = StubRoutines::generic_arraycopy();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2227
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2228
    // The arguments are in java calling convention so we shift them
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2229
    // to C convention
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2230
    assert_different_registers(c_rarg0, j_rarg1, j_rarg2, j_rarg3, j_rarg4);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2231
    __ mov(c_rarg0, j_rarg0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2232
    assert_different_registers(c_rarg1, j_rarg2, j_rarg3, j_rarg4);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2233
    __ mov(c_rarg1, j_rarg1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2234
    assert_different_registers(c_rarg2, j_rarg3, j_rarg4);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2235
    __ mov(c_rarg2, j_rarg2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2236
    assert_different_registers(c_rarg3, j_rarg4);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2237
    __ mov(c_rarg3, j_rarg3);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2238
    __ mov(c_rarg4, j_rarg4);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2239
    if (copyfunc_addr == NULL) { // Use C version if stub was not generated
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2240
      __ mov(rscratch1, RuntimeAddress(C_entry));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2241
      __ blrt(rscratch1, 5, 0, 1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2242
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2243
#ifndef PRODUCT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2244
      if (PrintC1Statistics) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2245
        __ incrementw(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2246
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2247
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2248
      __ far_call(RuntimeAddress(copyfunc_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2249
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2250
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2251
    __ cbz(r0, *stub->continuation());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2252
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2253
    // Reload values from the stack so they are where the stub
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2254
    // expects them.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2255
    __ ldp(dst,     dst_pos, Address(sp, 0*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2256
    __ ldp(length,  src_pos, Address(sp, 2*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2257
    __ ldr(src,              Address(sp, 4*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2258
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2259
    if (copyfunc_addr != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2260
      // r0 is -1^K where K == partial copied count
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2261
      __ eonw(rscratch1, r0, 0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2262
      // adjust length down and src/end pos up by partial copied count
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2263
      __ subw(length, length, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2264
      __ addw(src_pos, src_pos, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2265
      __ addw(dst_pos, dst_pos, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2266
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2267
    __ b(*stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2268
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2269
    __ bind(*stub->continuation());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2270
    return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2271
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2272
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2273
  assert(default_type != NULL && default_type->is_array_klass() && default_type->is_loaded(), "must be true at this point");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2274
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2275
  int elem_size = type2aelembytes(basic_type);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2276
  int shift_amount;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2277
  int scale = exact_log2(elem_size);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2278
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2279
  Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2280
  Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2281
  Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2282
  Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2283
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2284
  // test for NULL
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2285
  if (flags & LIR_OpArrayCopy::src_null_check) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2286
    __ cbz(src, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2287
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2288
  if (flags & LIR_OpArrayCopy::dst_null_check) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2289
    __ cbz(dst, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2290
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2291
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2292
  // check if negative
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2293
  if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2294
    __ cmpw(src_pos, 0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2295
    __ br(Assembler::LT, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2296
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2297
  if (flags & LIR_OpArrayCopy::dst_pos_positive_check) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2298
    __ cmpw(dst_pos, 0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2299
    __ br(Assembler::LT, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2300
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2301
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2302
  if (flags & LIR_OpArrayCopy::length_positive_check) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2303
    __ cmpw(length, 0);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2304
    __ br(Assembler::LT, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2305
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2306
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2307
  if (flags & LIR_OpArrayCopy::src_range_check) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2308
    __ addw(tmp, src_pos, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2309
    __ ldrw(rscratch1, src_length_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2310
    __ cmpw(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2311
    __ br(Assembler::HI, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2312
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2313
  if (flags & LIR_OpArrayCopy::dst_range_check) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2314
    __ addw(tmp, dst_pos, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2315
    __ ldrw(rscratch1, dst_length_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2316
    __ cmpw(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2317
    __ br(Assembler::HI, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2318
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2319
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2320
  // FIXME: The logic in LIRGenerator::arraycopy_helper clears
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2321
  // length_positive_check if the source of our length operand is an
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2322
  // arraylength.  However, that arraylength might be zero, and the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2323
  // stub that we're about to call contains an assertion that count !=
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2324
  // 0 .  So we make this check purely in order not to trigger an
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2325
  // assertion failure.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2326
  __ cbzw(length, *stub->continuation());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2327
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2328
  if (flags & LIR_OpArrayCopy::type_check) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2329
    // We don't know the array types are compatible
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2330
    if (basic_type != T_OBJECT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2331
      // Simple test for basic type arrays
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2332
      if (UseCompressedClassPointers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2333
        __ ldrw(tmp, src_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2334
        __ ldrw(rscratch1, dst_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2335
        __ cmpw(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2336
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2337
        __ ldr(tmp, src_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2338
        __ ldr(rscratch1, dst_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2339
        __ cmp(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2340
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2341
      __ br(Assembler::NE, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2342
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2343
      // For object arrays, if src is a sub class of dst then we can
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2344
      // safely do the copy.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2345
      Label cont, slow;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2346
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2347
#define PUSH(r1, r2)                                    \
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2348
      stp(r1, r2, __ pre(sp, -2 * wordSize));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2349
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2350
#define POP(r1, r2)                                     \
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2351
      ldp(r1, r2, __ post(sp, 2 * wordSize));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2352
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2353
      __ PUSH(src, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2354
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2355
      __ load_klass(src, src);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2356
      __ load_klass(dst, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2357
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2358
      __ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, NULL);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2359
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2360
      __ PUSH(src, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2361
      __ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2362
      __ POP(src, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2363
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2364
      __ cbnz(src, cont);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2365
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2366
      __ bind(slow);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2367
      __ POP(src, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2368
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2369
      address copyfunc_addr = StubRoutines::checkcast_arraycopy();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2370
      if (copyfunc_addr != NULL) { // use stub if available
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2371
        // src is not a sub class of dst so we have to do a
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2372
        // per-element check.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2373
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2374
        int mask = LIR_OpArrayCopy::src_objarray|LIR_OpArrayCopy::dst_objarray;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2375
        if ((flags & mask) != mask) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2376
          // Check that at least both of them object arrays.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2377
          assert(flags & mask, "one of the two should be known to be an object array");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2378
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2379
          if (!(flags & LIR_OpArrayCopy::src_objarray)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2380
            __ load_klass(tmp, src);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2381
          } else if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2382
            __ load_klass(tmp, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2383
          }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2384
          int lh_offset = in_bytes(Klass::layout_helper_offset());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2385
          Address klass_lh_addr(tmp, lh_offset);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2386
          jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2387
          __ ldrw(rscratch1, klass_lh_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2388
          __ mov(rscratch2, objArray_lh);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2389
          __ eorw(rscratch1, rscratch1, rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2390
          __ cbnzw(rscratch1, *stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2391
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2392
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2393
       // Spill because stubs can use any register they like and it's
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2394
       // easier to restore just those that we care about.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2395
        __ stp(dst,     dst_pos, Address(sp, 0*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2396
        __ stp(length,  src_pos, Address(sp, 2*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2397
        __ str(src,              Address(sp, 4*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2398
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2399
        __ lea(c_rarg0, Address(src, src_pos, Address::uxtw(scale)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2400
        __ add(c_rarg0, c_rarg0, arrayOopDesc::base_offset_in_bytes(basic_type));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2401
        assert_different_registers(c_rarg0, dst, dst_pos, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2402
        __ lea(c_rarg1, Address(dst, dst_pos, Address::uxtw(scale)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2403
        __ add(c_rarg1, c_rarg1, arrayOopDesc::base_offset_in_bytes(basic_type));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2404
        assert_different_registers(c_rarg1, dst, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2405
        __ uxtw(c_rarg2, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2406
        assert_different_registers(c_rarg2, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2407
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2408
        __ load_klass(c_rarg4, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2409
        __ ldr(c_rarg4, Address(c_rarg4, ObjArrayKlass::element_klass_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2410
        __ ldrw(c_rarg3, Address(c_rarg4, Klass::super_check_offset_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2411
        __ far_call(RuntimeAddress(copyfunc_addr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2412
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2413
#ifndef PRODUCT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2414
        if (PrintC1Statistics) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2415
          Label failed;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2416
          __ cbnz(r0, failed);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2417
          __ incrementw(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_cnt));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2418
          __ bind(failed);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2419
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2420
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2421
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2422
        __ cbz(r0, *stub->continuation());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2423
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2424
#ifndef PRODUCT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2425
        if (PrintC1Statistics) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2426
          __ incrementw(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_attempt_cnt));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2427
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2428
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2429
        assert_different_registers(dst, dst_pos, length, src_pos, src, r0, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2430
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2431
        // Restore previously spilled arguments
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2432
        __ ldp(dst,     dst_pos, Address(sp, 0*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2433
        __ ldp(length,  src_pos, Address(sp, 2*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2434
        __ ldr(src,              Address(sp, 4*BytesPerWord));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2435
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2436
        // return value is -1^K where K is partial copied count
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2437
        __ eonw(rscratch1, r0, zr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2438
        // adjust length down and src/end pos up by partial copied count
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2439
        __ subw(length, length, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2440
        __ addw(src_pos, src_pos, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2441
        __ addw(dst_pos, dst_pos, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2442
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2443
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2444
      __ b(*stub->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2445
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2446
      __ bind(cont);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2447
      __ POP(src, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2448
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2449
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2450
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2451
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2452
  if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2453
    // Sanity check the known type with the incoming class.  For the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2454
    // primitive case the types must match exactly with src.klass and
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2455
    // dst.klass each exactly matching the default type.  For the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2456
    // object array case, if no type check is needed then either the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2457
    // dst type is exactly the expected type and the src type is a
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2458
    // subtype which we can't check or src is the same array as dst
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2459
    // but not necessarily exactly of type default_type.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2460
    Label known_ok, halt;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2461
    __ mov_metadata(tmp, default_type->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2462
    if (UseCompressedClassPointers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2463
      __ encode_klass_not_null(tmp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2464
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2465
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2466
    if (basic_type != T_OBJECT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2467
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2468
      if (UseCompressedClassPointers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2469
        __ ldrw(rscratch1, dst_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2470
        __ cmpw(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2471
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2472
        __ ldr(rscratch1, dst_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2473
        __ cmp(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2474
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2475
      __ br(Assembler::NE, halt);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2476
      if (UseCompressedClassPointers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2477
        __ ldrw(rscratch1, src_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2478
        __ cmpw(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2479
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2480
        __ ldr(rscratch1, src_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2481
        __ cmp(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2482
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2483
      __ br(Assembler::EQ, known_ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2484
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2485
      if (UseCompressedClassPointers) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2486
        __ ldrw(rscratch1, dst_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2487
        __ cmpw(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2488
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2489
        __ ldr(rscratch1, dst_klass_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2490
        __ cmp(tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2491
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2492
      __ br(Assembler::EQ, known_ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2493
      __ cmp(src, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2494
      __ br(Assembler::EQ, known_ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2495
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2496
    __ bind(halt);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2497
    __ stop("incorrect type information in arraycopy");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2498
    __ bind(known_ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2499
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2500
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2501
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2502
#ifndef PRODUCT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2503
  if (PrintC1Statistics) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2504
    __ incrementw(ExternalAddress(Runtime1::arraycopy_count_address(basic_type)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2505
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2506
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2507
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2508
  __ lea(c_rarg0, Address(src, src_pos, Address::uxtw(scale)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2509
  __ add(c_rarg0, c_rarg0, arrayOopDesc::base_offset_in_bytes(basic_type));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2510
  assert_different_registers(c_rarg0, dst, dst_pos, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2511
  __ lea(c_rarg1, Address(dst, dst_pos, Address::uxtw(scale)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2512
  __ add(c_rarg1, c_rarg1, arrayOopDesc::base_offset_in_bytes(basic_type));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2513
  assert_different_registers(c_rarg1, dst, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2514
  __ uxtw(c_rarg2, length);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2515
  assert_different_registers(c_rarg2, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2516
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2517
  bool disjoint = (flags & LIR_OpArrayCopy::overlapping) == 0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2518
  bool aligned = (flags & LIR_OpArrayCopy::unaligned) == 0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2519
  const char *name;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2520
  address entry = StubRoutines::select_arraycopy_function(basic_type, aligned, disjoint, name, false);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2521
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2522
 CodeBlob *cb = CodeCache::find_blob(entry);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2523
 if (cb) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2524
   __ far_call(RuntimeAddress(entry));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2525
 } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2526
   __ call_VM_leaf(entry, 3);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2527
 }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2528
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2529
  __ bind(*stub->continuation());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2530
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2531
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2532
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2533
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2534
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2535
void LIR_Assembler::emit_lock(LIR_OpLock* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2536
  Register obj = op->obj_opr()->as_register();  // may not be an oop
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2537
  Register hdr = op->hdr_opr()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2538
  Register lock = op->lock_opr()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2539
  if (!UseFastLocking) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2540
    __ b(*op->stub()->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2541
  } else if (op->code() == lir_lock) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2542
    Register scratch = noreg;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2543
    if (UseBiasedLocking) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2544
      scratch = op->scratch_opr()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2545
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2546
    assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2547
    // add debug info for NullPointerException only if one is possible
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2548
    int null_check_offset = __ lock_object(hdr, obj, lock, scratch, *op->stub()->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2549
    if (op->info() != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2550
      add_debug_info_for_null_check(null_check_offset, op->info());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2551
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2552
    // done
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2553
  } else if (op->code() == lir_unlock) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2554
    assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2555
    __ unlock_object(hdr, obj, lock, *op->stub()->entry());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2556
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2557
    Unimplemented();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2558
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2559
  __ bind(*op->stub()->continuation());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2560
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2561
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2562
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2563
void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2564
  ciMethod* method = op->profiled_method();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2565
  int bci          = op->profiled_bci();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2566
  ciMethod* callee = op->profiled_callee();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2567
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2568
  // Update counter for all call types
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2569
  ciMethodData* md = method->method_data_or_null();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2570
  assert(md != NULL, "Sanity");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2571
  ciProfileData* data = md->bci_to_data(bci);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2572
  assert(data->is_CounterData(), "need CounterData for calls");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2573
  assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2574
  Register mdo  = op->mdo()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2575
  __ mov_metadata(mdo, md->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2576
  Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2577
  Bytecodes::Code bc = method->java_code_at_bci(bci);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2578
  const bool callee_is_static = callee->is_loaded() && callee->is_static();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2579
  // Perform additional virtual call profiling for invokevirtual and
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2580
  // invokeinterface bytecodes
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2581
  if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) &&
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2582
      !callee_is_static &&  // required for optimized MH invokes
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2583
      C1ProfileVirtualCalls) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2584
    assert(op->recv()->is_single_cpu(), "recv must be allocated");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2585
    Register recv = op->recv()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2586
    assert_different_registers(mdo, recv);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2587
    assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2588
    ciKlass* known_klass = op->known_holder();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2589
    if (C1OptimizeVirtualCallProfiling && known_klass != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2590
      // We know the type that will be seen at this call site; we can
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2591
      // statically update the MethodData* rather than needing to do
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2592
      // dynamic tests on the receiver type
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2593
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2594
      // NOTE: we should probably put a lock around this search to
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2595
      // avoid collisions by concurrent compilations
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2596
      ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2597
      uint i;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2598
      for (i = 0; i < VirtualCallData::row_limit(); i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2599
        ciKlass* receiver = vc_data->receiver(i);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2600
        if (known_klass->equals(receiver)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2601
          Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2602
          __ addptr(data_addr, DataLayout::counter_increment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2603
          return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2604
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2605
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2606
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2607
      // Receiver type not found in profile data; select an empty slot
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2608
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2609
      // Note that this is less efficient than it should be because it
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2610
      // always does a write to the receiver part of the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2611
      // VirtualCallData rather than just the first time
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2612
      for (i = 0; i < VirtualCallData::row_limit(); i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2613
        ciKlass* receiver = vc_data->receiver(i);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2614
        if (receiver == NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2615
          Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2616
          __ mov_metadata(rscratch1, known_klass->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2617
          __ lea(rscratch2, recv_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2618
          __ str(rscratch1, Address(rscratch2));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2619
          Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2620
          __ addptr(data_addr, DataLayout::counter_increment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2621
          return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2622
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2623
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2624
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2625
      __ load_klass(recv, recv);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2626
      Label update_done;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2627
      type_profile_helper(mdo, md, data, recv, &update_done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2628
      // Receiver did not match any saved receiver and there is no empty row for it.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2629
      // Increment total counter to indicate polymorphic case.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2630
      __ addptr(counter_addr, DataLayout::counter_increment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2631
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2632
      __ bind(update_done);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2633
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2634
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2635
    // Static call
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2636
    __ addptr(counter_addr, DataLayout::counter_increment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2637
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2638
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2639
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2640
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2641
void LIR_Assembler::emit_delay(LIR_OpDelay*) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2642
  Unimplemented();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2643
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2644
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2645
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2646
void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2647
  __ lea(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2648
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2649
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2650
void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2651
  assert(op->crc()->is_single_cpu(),  "crc must be register");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2652
  assert(op->val()->is_single_cpu(),  "byte value must be register");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2653
  assert(op->result_opr()->is_single_cpu(), "result must be register");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2654
  Register crc = op->crc()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2655
  Register val = op->val()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2656
  Register res = op->result_opr()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2657
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2658
  assert_different_registers(val, crc, res);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2659
  unsigned long offset;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2660
  __ adrp(res, ExternalAddress(StubRoutines::crc_table_addr()), offset);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2661
  if (offset) __ add(res, res, offset);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2662
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2663
  __ ornw(crc, zr, crc); // ~crc
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2664
  __ update_byte_crc32(crc, val, res);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2665
  __ ornw(res, zr, crc); // ~crc
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2666
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2667
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2668
void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2669
  COMMENT("emit_profile_type {");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2670
  Register obj = op->obj()->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2671
  Register tmp = op->tmp()->as_pointer_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2672
  Address mdo_addr = as_Address(op->mdp()->as_address_ptr());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2673
  ciKlass* exact_klass = op->exact_klass();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2674
  intptr_t current_klass = op->current_klass();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2675
  bool not_null = op->not_null();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2676
  bool no_conflict = op->no_conflict();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2677
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2678
  Label update, next, none;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2679
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2680
  bool do_null = !not_null;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2681
  bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2682
  bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2683
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2684
  assert(do_null || do_update, "why are we here?");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2685
  assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2686
  assert(mdo_addr.base() != rscratch1, "wrong register");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2687
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2688
  __ verify_oop(obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2689
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2690
  if (tmp != obj) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2691
    __ mov(tmp, obj);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2692
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2693
  if (do_null) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2694
    __ cbnz(tmp, update);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2695
    if (!TypeEntries::was_null_seen(current_klass)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2696
      __ ldr(rscratch2, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2697
      __ orr(rscratch2, rscratch2, TypeEntries::null_seen);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2698
      __ str(rscratch2, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2699
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2700
    if (do_update) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2701
#ifndef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2702
      __ b(next);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2703
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2704
#else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2705
      __ b(next);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2706
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2707
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2708
    __ cbnz(tmp, update);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2709
    __ stop("unexpected null obj");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2710
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2711
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2712
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2713
  __ bind(update);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2714
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2715
  if (do_update) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2716
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2717
    if (exact_klass != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2718
      Label ok;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2719
      __ load_klass(tmp, tmp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2720
      __ mov_metadata(rscratch1, exact_klass->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2721
      __ eor(rscratch1, tmp, rscratch1);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2722
      __ cbz(rscratch1, ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2723
      __ stop("exact klass and actual klass differ");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2724
      __ bind(ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2725
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2726
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2727
    if (!no_conflict) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2728
      if (exact_klass == NULL || TypeEntries::is_type_none(current_klass)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2729
        if (exact_klass != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2730
          __ mov_metadata(tmp, exact_klass->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2731
        } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2732
          __ load_klass(tmp, tmp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2733
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2734
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2735
        __ ldr(rscratch2, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2736
        __ eor(tmp, tmp, rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2737
        __ andr(rscratch1, tmp, TypeEntries::type_klass_mask);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2738
        // klass seen before, nothing to do. The unknown bit may have been
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2739
        // set already but no need to check.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2740
        __ cbz(rscratch1, next);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2741
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2742
        __ andr(rscratch1, tmp, TypeEntries::type_unknown);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2743
        __ cbnz(rscratch1, next); // already unknown. Nothing to do anymore.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2744
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2745
        if (TypeEntries::is_type_none(current_klass)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2746
          __ cbz(rscratch2, none);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2747
          __ cmp(rscratch2, TypeEntries::null_seen);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2748
          __ br(Assembler::EQ, none);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2749
          // There is a chance that the checks above (re-reading profiling
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2750
          // data from memory) fail if another thread has just set the
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2751
          // profiling to this obj's klass
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2752
          __ dmb(Assembler::ISHLD);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2753
          __ ldr(rscratch2, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2754
          __ eor(tmp, tmp, rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2755
          __ andr(rscratch1, tmp, TypeEntries::type_klass_mask);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2756
          __ cbz(rscratch1, next);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2757
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2758
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2759
        assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2760
               ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2761
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2762
        __ ldr(tmp, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2763
        __ andr(rscratch1, tmp, TypeEntries::type_unknown);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2764
        __ cbnz(rscratch1, next); // already unknown. Nothing to do anymore.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2765
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2766
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2767
      // different than before. Cannot keep accurate profile.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2768
      __ ldr(rscratch2, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2769
      __ orr(rscratch2, rscratch2, TypeEntries::type_unknown);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2770
      __ str(rscratch2, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2771
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2772
      if (TypeEntries::is_type_none(current_klass)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2773
        __ b(next);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2774
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2775
        __ bind(none);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2776
        // first time here. Set profile type.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2777
        __ str(tmp, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2778
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2779
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2780
      // There's a single possible klass at this profile point
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2781
      assert(exact_klass != NULL, "should be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2782
      if (TypeEntries::is_type_none(current_klass)) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2783
        __ mov_metadata(tmp, exact_klass->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2784
        __ ldr(rscratch2, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2785
        __ eor(tmp, tmp, rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2786
        __ andr(rscratch1, tmp, TypeEntries::type_klass_mask);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2787
        __ cbz(rscratch1, next);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2788
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2789
        {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2790
          Label ok;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2791
          __ ldr(rscratch1, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2792
          __ cbz(rscratch1, ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2793
          __ cmp(rscratch1, TypeEntries::null_seen);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2794
          __ br(Assembler::EQ, ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2795
          // may have been set by another thread
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2796
          __ dmb(Assembler::ISHLD);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2797
          __ mov_metadata(rscratch1, exact_klass->constant_encoding());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2798
          __ ldr(rscratch2, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2799
          __ eor(rscratch2, rscratch1, rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2800
          __ andr(rscratch2, rscratch2, TypeEntries::type_mask);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2801
          __ cbz(rscratch2, ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2802
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2803
          __ stop("unexpected profiling mismatch");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2804
          __ bind(ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2805
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2806
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2807
        // first time here. Set profile type.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2808
        __ ldr(tmp, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2809
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2810
        assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2811
               ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2812
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2813
        __ ldr(tmp, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2814
        __ andr(rscratch1, tmp, TypeEntries::type_unknown);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2815
        __ cbnz(rscratch1, next); // already unknown. Nothing to do anymore.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2816
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2817
        __ orr(tmp, tmp, TypeEntries::type_unknown);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2818
        __ str(tmp, mdo_addr);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2819
        // FIXME: Write barrier needed here?
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2820
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2821
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2822
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2823
    __ bind(next);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2824
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2825
  COMMENT("} emit_profile_type");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2826
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2827
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2828
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2829
void LIR_Assembler::align_backward_branch_target() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2830
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2831
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2832
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2833
void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2834
  if (left->is_single_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2835
    assert(dest->is_single_cpu(), "expect single result reg");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2836
    __ negw(dest->as_register(), left->as_register());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2837
  } else if (left->is_double_cpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2838
    assert(dest->is_double_cpu(), "expect double result reg");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2839
    __ neg(dest->as_register_lo(), left->as_register_lo());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2840
  } else if (left->is_single_fpu()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2841
    assert(dest->is_single_fpu(), "expect single float result reg");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2842
    __ fnegs(dest->as_float_reg(), left->as_float_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2843
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2844
    assert(left->is_double_fpu(), "expect double float operand reg");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2845
    assert(dest->is_double_fpu(), "expect double float result reg");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2846
    __ fnegd(dest->as_double_reg(), left->as_double_reg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2847
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2848
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2849
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2850
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2851
void LIR_Assembler::leal(LIR_Opr addr, LIR_Opr dest) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2852
  __ lea(dest->as_register_lo(), as_Address(addr->as_address_ptr()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2853
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2854
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2855
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2856
void LIR_Assembler::rt_call(LIR_Opr result, address dest, const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2857
  assert(!tmp->is_valid(), "don't need temporary");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2858
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2859
  CodeBlob *cb = CodeCache::find_blob(dest);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2860
  if (cb) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2861
    __ far_call(RuntimeAddress(dest));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2862
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2863
    __ mov(rscratch1, RuntimeAddress(dest));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2864
    int len = args->length();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2865
    int type = 0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2866
    if (! result->is_illegal()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2867
      switch (result->type()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2868
      case T_VOID:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2869
        type = 0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2870
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2871
      case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2872
      case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2873
      case T_OBJECT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2874
        type = 1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2875
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2876
      case T_FLOAT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2877
        type = 2;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2878
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2879
      case T_DOUBLE:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2880
        type = 3;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2881
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2882
      default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2883
        ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2884
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2885
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2886
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2887
    int num_gpargs = 0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2888
    int num_fpargs = 0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2889
    for (int i = 0; i < args->length(); i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2890
      LIR_Opr arg = args->at(i);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2891
      if (arg->type() == T_FLOAT || arg->type() == T_DOUBLE) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2892
        num_fpargs++;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2893
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2894
        num_gpargs++;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2895
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2896
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2897
    __ blrt(rscratch1, num_gpargs, num_fpargs, type);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2898
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2899
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2900
  if (info != NULL) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2901
    add_call_info_here(info);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2902
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2903
  __ maybe_isb();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2904
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2905
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2906
void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2907
  if (dest->is_address() || src->is_address()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2908
    move_op(src, dest, type, lir_patch_none, info,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2909
            /*pop_fpu_stack*/false, /*unaligned*/false, /*wide*/false);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2910
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2911
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2912
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2913
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2914
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2915
#ifdef ASSERT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2916
// emit run-time assertion
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2917
void LIR_Assembler::emit_assert(LIR_OpAssert* op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2918
  assert(op->code() == lir_assert, "must be");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2919
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2920
  if (op->in_opr1()->is_valid()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2921
    assert(op->in_opr2()->is_valid(), "both operands must be valid");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2922
    comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2923
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2924
    assert(op->in_opr2()->is_illegal(), "both operands must be illegal");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2925
    assert(op->condition() == lir_cond_always, "no other conditions allowed");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2926
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2927
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2928
  Label ok;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2929
  if (op->condition() != lir_cond_always) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2930
    Assembler::Condition acond = Assembler::AL;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2931
    switch (op->condition()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2932
      case lir_cond_equal:        acond = Assembler::EQ;  break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2933
      case lir_cond_notEqual:     acond = Assembler::NE;  break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2934
      case lir_cond_less:         acond = Assembler::LT;  break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2935
      case lir_cond_lessEqual:    acond = Assembler::LE;  break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2936
      case lir_cond_greaterEqual: acond = Assembler::GE;  break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2937
      case lir_cond_greater:      acond = Assembler::GT;  break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2938
      case lir_cond_belowEqual:   acond = Assembler::LS;  break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2939
      case lir_cond_aboveEqual:   acond = Assembler::HS;  break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2940
      default:                    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2941
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2942
    __ br(acond, ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2943
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2944
  if (op->halt()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2945
    const char* str = __ code_string(op->msg());
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2946
    __ stop(str);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2947
  } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2948
    breakpoint();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2949
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2950
  __ bind(ok);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2951
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2952
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2953
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2954
#ifndef PRODUCT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2955
#define COMMENT(x)   do { __ block_comment(x); } while (0)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2956
#else
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2957
#define COMMENT(x)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2958
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2959
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2960
void LIR_Assembler::membar() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2961
  COMMENT("membar");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2962
  __ membar(MacroAssembler::AnyAny);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2963
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2964
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2965
void LIR_Assembler::membar_acquire() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2966
  __ membar(Assembler::LoadLoad|Assembler::LoadStore);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2967
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2968
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2969
void LIR_Assembler::membar_release() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2970
  __ membar(Assembler::LoadStore|Assembler::StoreStore);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2971
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2972
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2973
void LIR_Assembler::membar_loadload() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2974
  __ membar(Assembler::LoadLoad);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2975
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2976
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2977
void LIR_Assembler::membar_storestore() {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2978
  __ membar(MacroAssembler::StoreStore);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2979
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2980
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2981
void LIR_Assembler::membar_loadstore() { __ membar(MacroAssembler::LoadStore); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2982
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2983
void LIR_Assembler::membar_storeload() { __ membar(MacroAssembler::StoreLoad); }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2984
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2985
void LIR_Assembler::get_thread(LIR_Opr result_reg) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2986
  __ mov(result_reg->as_register(), rthread);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2987
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2988
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2989
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2990
void LIR_Assembler::peephole(LIR_List *lir) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2991
#if 0
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2992
  if (tableswitch_count >= max_tableswitches)
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2993
    return;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2994
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2995
  /*
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2996
    This finite-state automaton recognizes sequences of compare-and-
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2997
    branch instructions.  We will turn them into a tableswitch.  You
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2998
    could argue that C1 really shouldn't be doing this sort of
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  2999
    optimization, but without it the code is really horrible.
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3000
  */
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3001
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3002
  enum { start_s, cmp1_s, beq_s, cmp_s } state;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3003
  int first_key, last_key = -2147483648;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3004
  int next_key = 0;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3005
  int start_insn = -1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3006
  int last_insn = -1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3007
  Register reg = noreg;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3008
  LIR_Opr reg_opr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3009
  state = start_s;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3010
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3011
  LIR_OpList* inst = lir->instructions_list();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3012
  for (int i = 0; i < inst->length(); i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3013
    LIR_Op* op = inst->at(i);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3014
    switch (state) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3015
    case start_s:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3016
      first_key = -1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3017
      start_insn = i;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3018
      switch (op->code()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3019
      case lir_cmp:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3020
        LIR_Opr opr1 = op->as_Op2()->in_opr1();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3021
        LIR_Opr opr2 = op->as_Op2()->in_opr2();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3022
        if (opr1->is_cpu_register() && opr1->is_single_cpu()
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3023
            && opr2->is_constant()
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3024
            && opr2->type() == T_INT) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3025
          reg_opr = opr1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3026
          reg = opr1->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3027
          first_key = opr2->as_constant_ptr()->as_jint();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3028
          next_key = first_key + 1;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3029
          state = cmp_s;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3030
          goto next_state;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3031
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3032
        break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3033
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3034
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3035
    case cmp_s:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3036
      switch (op->code()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3037
      case lir_branch:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3038
        if (op->as_OpBranch()->cond() == lir_cond_equal) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3039
          state = beq_s;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3040
          last_insn = i;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3041
          goto next_state;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3042
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3043
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3044
      state = start_s;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3045
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3046
    case beq_s:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3047
      switch (op->code()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3048
      case lir_cmp: {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3049
        LIR_Opr opr1 = op->as_Op2()->in_opr1();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3050
        LIR_Opr opr2 = op->as_Op2()->in_opr2();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3051
        if (opr1->is_cpu_register() && opr1->is_single_cpu()
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3052
            && opr1->as_register() == reg
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3053
            && opr2->is_constant()
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3054
            && opr2->type() == T_INT
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3055
            && opr2->as_constant_ptr()->as_jint() == next_key) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3056
          last_key = next_key;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3057
          next_key++;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3058
          state = cmp_s;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3059
          goto next_state;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3060
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3061
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3062
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3063
      last_key = next_key;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3064
      state = start_s;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3065
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3066
    default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3067
      assert(false, "impossible state");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3068
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3069
    if (state == start_s) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3070
      if (first_key < last_key - 5L && reg != noreg) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3071
        {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3072
          // printf("found run register %d starting at insn %d low value %d high value %d\n",
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3073
          //        reg->encoding(),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3074
          //        start_insn, first_key, last_key);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3075
          //   for (int i = 0; i < inst->length(); i++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3076
          //     inst->at(i)->print();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3077
          //     tty->print("\n");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3078
          //   }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3079
          //   tty->print("\n");
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3080
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3081
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3082
        struct tableswitch *sw = &switches[tableswitch_count];
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3083
        sw->_insn_index = start_insn, sw->_first_key = first_key,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3084
          sw->_last_key = last_key, sw->_reg = reg;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3085
        inst->insert_before(last_insn + 1, new LIR_OpLabel(&sw->_after));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3086
        {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3087
          // Insert the new table of branches
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3088
          int offset = last_insn;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3089
          for (int n = first_key; n < last_key; n++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3090
            inst->insert_before
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3091
              (last_insn + 1,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3092
               new LIR_OpBranch(lir_cond_always, T_ILLEGAL,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3093
                                inst->at(offset)->as_OpBranch()->label()));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3094
            offset -= 2, i++;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3095
          }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3096
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3097
        // Delete all the old compare-and-branch instructions
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3098
        for (int n = first_key; n < last_key; n++) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3099
          inst->remove_at(start_insn);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3100
          inst->remove_at(start_insn);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3101
        }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3102
        // Insert the tableswitch instruction
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3103
        inst->insert_before(start_insn,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3104
                            new LIR_Op2(lir_cmp, lir_cond_always,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3105
                                        LIR_OprFact::intConst(tableswitch_count),
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3106
                                        reg_opr));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3107
        inst->insert_before(start_insn + 1, new LIR_OpLabel(&sw->_branches));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3108
        tableswitch_count++;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3109
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3110
      reg = noreg;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3111
      last_key = -2147483648;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3112
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3113
  next_state:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3114
    ;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3115
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3116
#endif
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3117
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3118
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3119
void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr dest, LIR_Opr tmp_op) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3120
  Address addr = as_Address(src->as_address_ptr(), noreg);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3121
  BasicType type = src->type();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3122
  bool is_oop = type == T_OBJECT || type == T_ARRAY;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3123
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3124
  void (MacroAssembler::* lda)(Register Rd, Register Ra);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3125
  void (MacroAssembler::* add)(Register Rd, Register Rn, RegisterOrConstant increment);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3126
  void (MacroAssembler::* stl)(Register Rs, Register Rt, Register Rn);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3127
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3128
  switch(type) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3129
  case T_INT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3130
    lda = &MacroAssembler::ldaxrw;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3131
    add = &MacroAssembler::addw;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3132
    stl = &MacroAssembler::stlxrw;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3133
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3134
  case T_LONG:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3135
    lda = &MacroAssembler::ldaxr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3136
    add = &MacroAssembler::add;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3137
    stl = &MacroAssembler::stlxr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3138
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3139
  case T_OBJECT:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3140
  case T_ARRAY:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3141
    if (UseCompressedOops) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3142
      lda = &MacroAssembler::ldaxrw;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3143
      add = &MacroAssembler::addw;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3144
      stl = &MacroAssembler::stlxrw;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3145
    } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3146
      lda = &MacroAssembler::ldaxr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3147
      add = &MacroAssembler::add;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3148
      stl = &MacroAssembler::stlxr;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3149
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3150
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3151
  default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3152
    ShouldNotReachHere();
35127
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  3153
    lda = &MacroAssembler::ldaxr;
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  3154
    add = &MacroAssembler::add;
483603d4c7b2 8145553: Fix warnings in AArch64 directory
aph
parents: 33628
diff changeset
  3155
    stl = &MacroAssembler::stlxr;  // unreachable
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3156
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3157
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3158
  switch (code) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3159
  case lir_xadd:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3160
    {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3161
      RegisterOrConstant inc;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3162
      Register tmp = as_reg(tmp_op);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3163
      Register dst = as_reg(dest);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3164
      if (data->is_constant()) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3165
        inc = RegisterOrConstant(as_long(data));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3166
        assert_different_registers(dst, addr.base(), tmp,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3167
                                   rscratch1, rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3168
      } else {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3169
        inc = RegisterOrConstant(as_reg(data));
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3170
        assert_different_registers(inc.as_register(), dst, addr.base(), tmp,
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3171
                                   rscratch1, rscratch2);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3172
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3173
      Label again;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3174
      __ lea(tmp, addr);
36565
8e38f7594806 8151340: aarch64: prefetch the destination word for write prior to ldxr/stxr loops.
fyang
parents: 36562
diff changeset
  3175
      __ prfm(Address(tmp), PSTL1STRM);
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3176
      __ bind(again);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3177
      (_masm->*lda)(dst, tmp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3178
      (_masm->*add)(rscratch1, dst, inc);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3179
      (_masm->*stl)(rscratch2, rscratch1, tmp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3180
      __ cbnzw(rscratch2, again);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3181
      break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3182
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3183
  case lir_xchg:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3184
    {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3185
      Register tmp = tmp_op->as_register();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3186
      Register obj = as_reg(data);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3187
      Register dst = as_reg(dest);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3188
      if (is_oop && UseCompressedOops) {
35584
bd3f4749a19c 8147805: aarch64: C1 segmentation fault due to inline Unsafe.getAndSetObject
hshi
parents: 35127
diff changeset
  3189
        __ encode_heap_oop(rscratch1, obj);
bd3f4749a19c 8147805: aarch64: C1 segmentation fault due to inline Unsafe.getAndSetObject
hshi
parents: 35127
diff changeset
  3190
        obj = rscratch1;
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3191
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3192
      assert_different_registers(obj, addr.base(), tmp, rscratch2, dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3193
      Label again;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3194
      __ lea(tmp, addr);
36565
8e38f7594806 8151340: aarch64: prefetch the destination word for write prior to ldxr/stxr loops.
fyang
parents: 36562
diff changeset
  3195
      __ prfm(Address(tmp), PSTL1STRM);
29184
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3196
      __ bind(again);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3197
      (_masm->*lda)(dst, tmp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3198
      (_masm->*stl)(rscratch2, obj, tmp);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3199
      __ cbnzw(rscratch2, again);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3200
      if (is_oop && UseCompressedOops) {
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3201
        __ decode_heap_oop(dst);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3202
      }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3203
    }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3204
    break;
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3205
  default:
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3206
    ShouldNotReachHere();
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3207
  }
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3208
  __ membar(__ AnyAny);
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3209
}
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3210
e234025cafb6 8068053: AARCH64: C1 and C2 compilers
aph
parents:
diff changeset
  3211
#undef __