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