src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp
author dlong
Wed, 31 Jan 2018 16:09:29 -0800
changeset 48856 c866eaca24cb
parent 47762 9ccaa4e79030
child 49397 d3a8aa01f26f
permissions -rw-r--r--
8194984: 9 Null pointer dereference defect groups related to ciMethodData::bci_to_data() Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
     3
 * Copyright (c) 2016, 2017, SAP SE. All rights reserved.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     5
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     9
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    14
 * accompanied this code).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    15
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    19
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    22
 * questions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    23
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    24
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    25
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    27
#include "c1/c1_Compilation.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "c1/c1_FrameMap.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "c1/c1_Instruction.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "c1/c1_LIRAssembler.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "c1/c1_LIRGenerator.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "c1/c1_Runtime1.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "c1/c1_ValueStack.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "ci/ciArray.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
#include "ci/ciObjArrayKlass.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#include "ci/ciTypeArrayKlass.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
#include "runtime/sharedRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
#include "runtime/stubRoutines.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
#include "vmreg_s390.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
#define __ gen()->lir(__FILE__, __LINE__)->
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
#else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
#define __ gen()->lir()->
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
void LIRItem::load_byte_item() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
  // Byte loads use same registers as other loads.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
  load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
void LIRItem::load_nonconstant(int bits) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
  LIR_Opr r = value()->operand();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
  if (_gen->can_inline_as_constant(value(), bits)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
    if (!r->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
      r = LIR_OprFact::value_type(value()->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
    _result = r;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
    load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
//--------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
//               LIRGenerator
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
//--------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
LIR_Opr LIRGenerator::exceptionOopOpr() { return FrameMap::as_oop_opr(Z_EXC_OOP); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
LIR_Opr LIRGenerator::exceptionPcOpr()  { return FrameMap::as_opr(Z_EXC_PC); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
LIR_Opr LIRGenerator::divInOpr()        { return FrameMap::Z_R11_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
LIR_Opr LIRGenerator::divOutOpr()       { return FrameMap::Z_R11_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
LIR_Opr LIRGenerator::remOutOpr()       { return FrameMap::Z_R10_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
LIR_Opr LIRGenerator::ldivInOpr()       { return FrameMap::Z_R11_long_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
LIR_Opr LIRGenerator::ldivOutOpr()      { return FrameMap::Z_R11_long_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
LIR_Opr LIRGenerator::lremOutOpr()      { return FrameMap::Z_R10_long_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
LIR_Opr LIRGenerator::syncLockOpr()     { return new_register(T_INT); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
LIR_Opr LIRGenerator::syncTempOpr()     { return FrameMap::Z_R13_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
LIR_Opr LIRGenerator::getThreadTemp()   { return LIR_OprFact::illegalOpr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
LIR_Opr LIRGenerator::result_register_for (ValueType* type, bool callee) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
  LIR_Opr opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
  switch (type->tag()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
    case intTag:    opr = FrameMap::Z_R2_opr;        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
    case objectTag: opr = FrameMap::Z_R2_oop_opr;    break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
    case longTag:   opr = FrameMap::Z_R2_long_opr;   break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
    case floatTag:  opr = FrameMap::Z_F0_opr;        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
    case doubleTag: opr = FrameMap::Z_F0_double_opr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
    case addressTag:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
    default: ShouldNotReachHere(); return LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
  assert(opr->type_field() == as_OprType(as_BasicType(type)), "type mismatch");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
  return opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
LIR_Opr LIRGenerator::rlock_byte(BasicType type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
  return new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
//--------- Loading items into registers. --------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
// z/Architecture cannot inline all constants.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
bool LIRGenerator::can_store_as_constant(Value v, BasicType type) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
  if (v->type()->as_IntConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
    return Immediate::is_simm16(v->type()->as_IntConstant()->value());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
  } else if (v->type()->as_LongConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
    return Immediate::is_simm16(v->type()->as_LongConstant()->value());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
  } else if (v->type()->as_ObjectConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
    return v->type()->as_ObjectConstant()->value()->is_null_object();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
    return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
bool LIRGenerator::can_inline_as_constant(Value i, int bits) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
  if (i->type()->as_IntConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
    return Assembler::is_simm(i->type()->as_IntConstant()->value(), bits);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
  } else if (i->type()->as_LongConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
    return Assembler::is_simm(i->type()->as_LongConstant()->value(), bits);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
    return can_store_as_constant(i, as_BasicType(i->type()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
bool LIRGenerator::can_inline_as_constant(LIR_Const* c) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
  if (c->type() == T_INT) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
    return Immediate::is_simm20(c->as_jint());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
  } else   if (c->type() == T_LONG) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
    return Immediate::is_simm20(c->as_jlong());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
  return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
LIR_Opr LIRGenerator::safepoint_poll_register() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
  return new_register(longType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
                                            int shift, int disp, BasicType type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
  assert(base->is_register(), "must be");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
  if (index->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
    intptr_t large_disp = ((intx)(index->as_constant_ptr()->as_jint()) << shift) + disp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
    if (Displacement::is_validDisp(large_disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
      return new LIR_Address(base, large_disp, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   147
    // Index is illegal so replace it with the displacement loaded into a register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   148
    index = new_pointer_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   149
    __ move(LIR_OprFact::intptrConst(large_disp), index);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   150
    return new LIR_Address(base, index, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   152
    if (shift > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   153
      LIR_Opr tmp = new_pointer_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   154
      __ shift_left(index, shift, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
      index = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
    return new LIR_Address(base, index, disp, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   159
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   160
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   161
LIR_Address* LIRGenerator::emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   162
                                              BasicType type, bool needs_card_mark) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   163
  int elem_size = type2aelembytes(type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   164
  int shift = exact_log2(elem_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   165
  int offset_in_bytes = arrayOopDesc::base_offset_in_bytes(type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   166
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   167
  LIR_Address* addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   168
  if (index_opr->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   169
    addr = new LIR_Address(array_opr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   170
                           offset_in_bytes + (intx)(index_opr->as_jint()) * elem_size, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   171
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   172
    if (index_opr->type() == T_INT) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   173
      LIR_Opr tmp = new_register(T_LONG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   174
      __ convert(Bytecodes::_i2l, index_opr, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   175
      index_opr = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   176
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   177
    if (shift > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   178
      __ shift_left(index_opr, shift, index_opr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   179
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   180
    addr = new LIR_Address(array_opr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   181
                           index_opr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   182
                           offset_in_bytes, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   183
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   184
  if (needs_card_mark) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   185
    // This store will need a precise card mark, so go ahead and
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   186
    // compute the full adddres instead of computing once for the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   187
    // store and again for the card mark.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   188
    LIR_Opr tmp = new_pointer_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   189
    __ leal(LIR_OprFact::address(addr), tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   190
    return new LIR_Address(tmp, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   191
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   192
    return addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   193
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   194
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   195
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   196
LIR_Opr LIRGenerator::load_immediate(int x, BasicType type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   197
  LIR_Opr r = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   198
  if (type == T_LONG) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   199
    r = LIR_OprFact::longConst(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   200
  } else if (type == T_INT) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   201
    r = LIR_OprFact::intConst(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   202
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   203
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   204
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   205
  return r;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   206
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   207
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   208
void LIRGenerator::increment_counter(address counter, BasicType type, int step) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   209
  LIR_Opr pointer = new_pointer_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   210
  __ move(LIR_OprFact::intptrConst(counter), pointer);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   211
  LIR_Address* addr = new LIR_Address(pointer, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   212
  increment_counter(addr, step);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   213
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   214
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   215
void LIRGenerator::increment_counter(LIR_Address* addr, int step) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   216
  __ add((LIR_Opr)addr, LIR_OprFact::intConst(step), (LIR_Opr)addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   217
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   218
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   219
void LIRGenerator::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   220
  LIR_Opr scratch = FrameMap::Z_R1_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   221
  __ load(new LIR_Address(base, disp, T_INT), scratch, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   222
  __ cmp(condition, scratch, c);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   223
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   224
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   225
void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   226
  __ cmp_reg_mem(condition, reg, new LIR_Address(base, disp, type), info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   227
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   228
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   229
void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   230
  __ cmp_reg_mem(condition, reg, new LIR_Address(base, disp, type), info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   231
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   232
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   233
bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   234
  if (tmp->is_valid()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   235
    if (is_power_of_2(c + 1)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   236
      __ move(left, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   237
      __ shift_left(left, log2_intptr(c + 1), left);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   238
      __ sub(left, tmp, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   239
      return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   240
    } else if (is_power_of_2(c - 1)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   241
      __ move(left, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   242
      __ shift_left(left, log2_intptr(c - 1), left);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   243
      __ add(left, tmp, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   244
      return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   245
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   246
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   247
  return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   248
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   249
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   250
void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   251
  BasicType type = item->type();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   252
  __ store(item, new LIR_Address(FrameMap::Z_SP_opr, in_bytes(offset_from_sp), type));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   253
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   254
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   255
//----------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   256
//             visitor functions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   257
//----------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   258
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   259
void LIRGenerator::do_StoreIndexed(StoreIndexed* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   260
  assert(x->is_pinned(),"");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   261
  bool needs_range_check = x->compute_needs_range_check();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   262
  bool use_length = x->length() != NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   263
  bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   264
  bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   265
                                         !get_jobject_constant(x->value())->is_null_object() ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   266
                                         x->should_profile());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   267
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   268
  LIRItem array(x->array(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   269
  LIRItem index(x->index(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   270
  LIRItem value(x->value(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   271
  LIRItem length(this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   272
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   273
  array.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   274
  index.load_nonconstant(20);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   275
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   276
  if (use_length && needs_range_check) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   277
    length.set_instruction(x->length());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   278
    length.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   279
  }
47762
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
   280
  if (needs_store_check || x->check_boolean()) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   281
    value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   282
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   283
    value.load_for_store(x->elt_type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   284
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   285
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   286
  set_no_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   287
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   288
  // The CodeEmitInfo must be duplicated for each different
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   289
  // LIR-instruction because spilling can occur anywhere between two
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   290
  // instructions and so the debug information must be different.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   291
  CodeEmitInfo* range_check_info = state_for (x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   292
  CodeEmitInfo* null_check_info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   293
  if (x->needs_null_check()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   294
    null_check_info = new CodeEmitInfo(range_check_info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   295
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   296
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   297
  // Emit array address setup early so it schedules better.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   298
  LIR_Address* array_addr = emit_array_address(array.result(), index.result(), x->elt_type(), obj_store);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   299
  if (value.result()->is_constant() && array_addr->index()->is_valid()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   300
    // Constants cannot be stored with index register on ZARCH_64 (see LIR_Assembler::const2mem()).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   301
    LIR_Opr tmp = new_pointer_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   302
    __ leal(LIR_OprFact::address(array_addr), tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   303
    array_addr = new LIR_Address(tmp, x->elt_type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   304
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   305
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   306
  if (GenerateRangeChecks && needs_range_check) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   307
    if (use_length) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   308
      __ cmp(lir_cond_belowEqual, length.result(), index.result());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   309
      __ branch(lir_cond_belowEqual, T_INT, new RangeCheckStub(range_check_info, index.result()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   310
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   311
      array_range_check(array.result(), index.result(), null_check_info, range_check_info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   312
      // Range_check also does the null check.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   313
      null_check_info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   314
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   315
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   316
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   317
  if (GenerateArrayStoreCheck && needs_store_check) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   318
    LIR_Opr tmp1 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   319
    LIR_Opr tmp2 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   320
    LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   321
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   322
    CodeEmitInfo* store_check_info = new CodeEmitInfo(range_check_info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   323
    __ store_check(value.result(), array.result(), tmp1, tmp2, tmp3, store_check_info, x->profiled_method(), x->profiled_bci());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   324
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   325
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   326
  if (obj_store) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   327
    // Needs GC write barriers.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   328
    pre_barrier(LIR_OprFact::address(array_addr), LIR_OprFact::illegalOpr /* pre_val */,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   329
                true /* do_load */, false /* patch */, NULL);
47762
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
   330
  }
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
   331
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
   332
  LIR_Opr result = maybe_mask_boolean(x, array.result(), value.result(), null_check_info);
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
   333
  __ move(result, array_addr, null_check_info);
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
   334
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
   335
  if (obj_store) {
9ccaa4e79030 8190285: s390: Some java boolean checks are not correct
mdoerr
parents: 47216
diff changeset
   336
    // Precise card mark
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   337
    post_barrier(LIR_OprFact::address(array_addr), value.result());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   338
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   339
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   340
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   341
void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   342
  assert(x->is_pinned(),"");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   343
  LIRItem obj(x->obj(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   344
  obj.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   345
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   346
  set_no_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   347
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   348
  // "lock" stores the address of the monitor stack slot, so this is not an oop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   349
  LIR_Opr lock = new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   350
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   351
  CodeEmitInfo* info_for_exception = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   352
  if (x->needs_null_check()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   353
    info_for_exception = state_for (x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   354
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   355
  // This CodeEmitInfo must not have the xhandlers because here the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   356
  // object is already locked (xhandlers expect object to be unlocked).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   357
  CodeEmitInfo* info = state_for (x, x->state(), true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   358
  monitor_enter(obj.result(), lock, syncTempOpr(), LIR_OprFact::illegalOpr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   359
                x->monitor_no(), info_for_exception, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   360
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   361
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   362
void LIRGenerator::do_MonitorExit(MonitorExit* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   363
  assert(x->is_pinned(),"");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   364
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   365
  LIRItem obj(x->obj(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   366
  obj.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   367
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   368
  LIR_Opr lock = new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   369
  LIR_Opr obj_temp = new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   370
  set_no_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   371
  monitor_exit(obj_temp, lock, syncTempOpr(), LIR_OprFact::illegalOpr, x->monitor_no());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   372
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   373
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   374
// _ineg, _lneg, _fneg, _dneg
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   375
void LIRGenerator::do_NegateOp(NegateOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   376
  LIRItem value(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   377
  value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   378
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   379
  __ negate(value.result(), reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   380
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   381
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   382
// for _fadd, _fmul, _fsub, _fdiv, _frem
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   383
//     _dadd, _dmul, _dsub, _ddiv, _drem
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   384
void LIRGenerator::do_ArithmeticOp_FPU(ArithmeticOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   385
  LIRItem left(x->x(),  this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   386
  LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   387
  LIRItem* left_arg  = &left;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   388
  LIRItem* right_arg = &right;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   389
  assert(!left.is_stack(), "can't both be memory operands");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   390
  left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   391
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   392
  if (right.is_register() || right.is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   393
    right.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   394
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   395
    right.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   396
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   397
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   398
  if ((x->op() == Bytecodes::_frem) || (x->op() == Bytecodes::_drem)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   399
    address entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   400
    switch (x->op()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   401
    case Bytecodes::_frem:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   402
      entry = CAST_FROM_FN_PTR(address, SharedRuntime::frem);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   403
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   404
    case Bytecodes::_drem:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   405
      entry = CAST_FROM_FN_PTR(address, SharedRuntime::drem);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   406
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   407
    default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   408
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   409
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   410
    LIR_Opr result = call_runtime(x->x(), x->y(), entry, x->type(), NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   411
    set_result(x, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   412
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   413
    LIR_Opr reg = rlock(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   414
    LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   415
    arithmetic_op_fpu(x->op(), reg, left.result(), right.result(), x->is_strictfp(), tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   416
    set_result(x, reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   417
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   418
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   419
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   420
// for _ladd, _lmul, _lsub, _ldiv, _lrem
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   421
void LIRGenerator::do_ArithmeticOp_Long(ArithmeticOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   422
  if (x->op() == Bytecodes::_ldiv || x->op() == Bytecodes::_lrem) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   423
    // Use shifts if divisior is a power of 2 otherwise use DSGR instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   424
    // Instruction: DSGR R1, R2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   425
    // input : R1+1: dividend   (R1, R1+1 designate a register pair, R1 must be even)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   426
    //         R2:   divisor
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   427
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   428
    // output: R1+1: quotient
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   429
    //         R1:   remainder
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   430
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   431
    // Register selection: R1:   Z_R10
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   432
    //                     R1+1: Z_R11
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   433
    //                     R2:   to be chosen by register allocator (linear scan)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   434
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   435
    // R1, and R1+1 will be destroyed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   436
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   437
    LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   438
    LIRItem left(x->x() , this);   // Visit left second, so that the is_register test is valid.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   439
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   440
    // Call state_for before load_item_force because state_for may
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   441
    // force the evaluation of other instructions that are needed for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   442
    // correct debug info. Otherwise the live range of the fix
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   443
    // register might be too long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   444
    CodeEmitInfo* info = state_for (x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   445
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   446
    LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   447
    LIR_Opr result_reg = result;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   448
    LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   449
    LIR_Opr divisor_opr = right.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   450
    if (divisor_opr->is_constant() && is_power_of_2(divisor_opr->as_jlong())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   451
      left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   452
      right.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   453
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   454
      left.load_item_force(ldivInOpr());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   455
      right.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   456
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   457
      // DSGR instruction needs register pair.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   458
      if (x->op() == Bytecodes::_ldiv) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   459
        result_reg = ldivOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   460
        tmp        = lremOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   461
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   462
        result_reg = lremOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   463
        tmp        = ldivOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   464
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   465
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   466
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   467
    if (!ImplicitDiv0Checks) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   468
      __ cmp(lir_cond_equal, right.result(), LIR_OprFact::longConst(0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   469
      __ branch(lir_cond_equal, T_LONG, new DivByZeroStub(info));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   470
      // Idiv/irem cannot trap (passing info would generate an assertion).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   471
      info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   472
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   473
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   474
    if (x->op() == Bytecodes::_lrem) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   475
      __ irem(left.result(), right.result(), result_reg, tmp, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   476
    } else if (x->op() == Bytecodes::_ldiv) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   477
      __ idiv(left.result(), right.result(), result_reg, tmp, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   478
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   479
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   480
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   481
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   482
    if (result_reg != result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   483
      __ move(result_reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   484
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   485
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   486
    LIRItem left(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   487
    LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   488
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   489
    left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   490
    right.load_nonconstant(32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   491
    rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   492
    arithmetic_op_long(x->op(), x->operand(), left.result(), right.result(), NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   493
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   494
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   495
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   496
// for: _iadd, _imul, _isub, _idiv, _irem
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   497
void LIRGenerator::do_ArithmeticOp_Int(ArithmeticOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   498
  if (x->op() == Bytecodes::_idiv || x->op() == Bytecodes::_irem) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   499
    // Use shifts if divisior is a power of 2 otherwise use DSGFR instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   500
    // Instruction: DSGFR R1, R2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   501
    // input : R1+1: dividend   (R1, R1+1 designate a register pair, R1 must be even)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   502
    //         R2:   divisor
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   503
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   504
    // output: R1+1: quotient
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   505
    //         R1:   remainder
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   506
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   507
    // Register selection: R1:   Z_R10
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   508
    //                     R1+1: Z_R11
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   509
    //                     R2:   To be chosen by register allocator (linear scan).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   510
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   511
    // R1, and R1+1 will be destroyed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   512
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   513
    LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   514
    LIRItem left(x->x() , this);   // Visit left second, so that the is_register test is valid.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   515
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   516
    // Call state_for before load_item_force because state_for may
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   517
    // force the evaluation of other instructions that are needed for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   518
    // correct debug info. Otherwise the live range of the fix
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   519
    // register might be too long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   520
    CodeEmitInfo* info = state_for (x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   521
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   522
    LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   523
    LIR_Opr result_reg = result;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   524
    LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   525
    LIR_Opr divisor_opr = right.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   526
    if (divisor_opr->is_constant() && is_power_of_2(divisor_opr->as_jint())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   527
      left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   528
      right.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   529
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   530
      left.load_item_force(divInOpr());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   531
      right.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   532
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   533
      // DSGFR instruction needs register pair.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   534
      if (x->op() == Bytecodes::_idiv) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   535
        result_reg = divOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   536
        tmp        = remOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   537
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   538
        result_reg = remOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   539
        tmp        = divOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   540
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   541
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   542
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   543
    if (!ImplicitDiv0Checks) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   544
      __ cmp(lir_cond_equal, right.result(), LIR_OprFact::intConst(0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   545
      __ branch(lir_cond_equal, T_INT, new DivByZeroStub(info));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   546
      // Idiv/irem cannot trap (passing info would generate an assertion).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   547
      info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   548
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   549
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   550
    if (x->op() == Bytecodes::_irem) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   551
      __ irem(left.result(), right.result(), result_reg, tmp, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   552
    } else if (x->op() == Bytecodes::_idiv) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   553
      __ idiv(left.result(), right.result(), result_reg, tmp, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   554
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   555
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   556
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   557
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   558
    if (result_reg != result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   559
      __ move(result_reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   560
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   561
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   562
    LIRItem left(x->x(),  this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   563
    LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   564
    LIRItem* left_arg = &left;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   565
    LIRItem* right_arg = &right;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   566
    if (x->is_commutative() && left.is_stack() && right.is_register()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   567
      // swap them if left is real stack (or cached) and right is real register(not cached)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   568
      left_arg = &right;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   569
      right_arg = &left;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   570
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   571
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   572
    left_arg->load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   573
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   574
    // Do not need to load right, as we can handle stack and constants.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   575
    if (x->op() == Bytecodes::_imul) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   576
      bool use_tmp = false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   577
      if (right_arg->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   578
        int iconst = right_arg->get_jint_constant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   579
        if (is_power_of_2(iconst - 1) || is_power_of_2(iconst + 1)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   580
          use_tmp = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   581
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   582
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   583
      right_arg->dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   584
      LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   585
      if (use_tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   586
        tmp = new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   587
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   588
      rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   589
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   590
      arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   591
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   592
      right_arg->dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   593
      rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   594
      LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   595
      arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   596
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   597
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   598
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   599
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   600
void LIRGenerator::do_ArithmeticOp(ArithmeticOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   601
  // If an operand with use count 1 is the left operand, then it is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   602
  // likely that no move for 2-operand-LIR-form is necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   603
  if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   604
    x->swap_operands();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   605
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   606
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   607
  ValueTag tag = x->type()->tag();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   608
  assert(x->x()->type()->tag() == tag && x->y()->type()->tag() == tag, "wrong parameters");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   609
  switch (tag) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   610
    case floatTag:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   611
    case doubleTag: do_ArithmeticOp_FPU(x);  return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   612
    case longTag:   do_ArithmeticOp_Long(x); return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   613
    case intTag:    do_ArithmeticOp_Int(x);  return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   614
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   615
  ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   616
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   617
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   618
// _ishl, _lshl, _ishr, _lshr, _iushr, _lushr
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   619
void LIRGenerator::do_ShiftOp(ShiftOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   620
  // count must always be in rcx
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   621
  LIRItem value(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   622
  LIRItem count(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   623
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   624
  ValueTag elemType = x->type()->tag();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   625
  bool must_load_count = !count.is_constant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   626
  if (must_load_count) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   627
    count.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   628
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   629
    count.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   630
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   631
  value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   632
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   633
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   634
  shift_op(x->op(), reg, value.result(), count.result(), LIR_OprFact::illegalOpr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   635
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   636
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   637
// _iand, _land, _ior, _lor, _ixor, _lxor
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   638
void LIRGenerator::do_LogicOp(LogicOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   639
  // IF an operand with use count 1 is the left operand, then it is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   640
  // likely that no move for 2-operand-LIR-form is necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   641
  if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   642
    x->swap_operands();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   643
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   644
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   645
  LIRItem left(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   646
  LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   647
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   648
  left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   649
  right.load_nonconstant(32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   650
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   651
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   652
  logic_op(x->op(), reg, left.result(), right.result());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   653
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   654
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   655
// _lcmp, _fcmpl, _fcmpg, _dcmpl, _dcmpg
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   656
void LIRGenerator::do_CompareOp(CompareOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   657
  LIRItem left(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   658
  LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   659
  left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   660
  right.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   661
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   662
  if (x->x()->type()->is_float_kind()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   663
    Bytecodes::Code code = x->op();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   664
    __ fcmp2int(left.result(), right.result(), reg, (code == Bytecodes::_fcmpl || code == Bytecodes::_dcmpl));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   665
  } else if (x->x()->type()->tag() == longTag) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   666
    __ lcmp2int(left.result(), right.result(), reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   667
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   668
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   669
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   670
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   671
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   672
void LIRGenerator::do_CompareAndSwap(Intrinsic* x, ValueType* type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   673
  assert(x->number_of_arguments() == 4, "wrong type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   674
  LIRItem obj   (x->argument_at(0), this);  // object
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   675
  LIRItem offset(x->argument_at(1), this);  // offset of field
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   676
  LIRItem cmp   (x->argument_at(2), this);  // Value to compare with field.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   677
  LIRItem val   (x->argument_at(3), this);  // Replace field with val if matches cmp.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   678
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   679
  // Get address of field.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   680
  obj.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   681
  offset.load_nonconstant(20);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   682
  cmp.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   683
  val.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   684
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   685
  LIR_Opr addr = new_pointer_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   686
  LIR_Address* a;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   687
  if (offset.result()->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   688
    assert(Immediate::is_simm20(offset.result()->as_jlong()), "should have been loaded into register");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   689
    a = new LIR_Address(obj.result(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   690
                        offset.result()->as_jlong(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   691
                        as_BasicType(type));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   692
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   693
    a = new LIR_Address(obj.result(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   694
                        offset.result(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   695
                        0,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   696
                        as_BasicType(type));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   697
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   698
  __ leal(LIR_OprFact::address(a), addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   699
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   700
  if (type == objectType) {  // Write-barrier needed for Object fields.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   701
    pre_barrier(addr, LIR_OprFact::illegalOpr /* pre_val */,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   702
                true /* do_load */, false /* patch */, NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   703
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   704
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   705
  LIR_Opr ill = LIR_OprFact::illegalOpr;  // for convenience
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   706
  if (type == objectType) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   707
    __ cas_obj(addr, cmp.result(), val.result(), new_register(T_OBJECT), new_register(T_OBJECT));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   708
  } else if (type == intType) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   709
    __ cas_int(addr, cmp.result(), val.result(), ill, ill);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   710
  } else if (type == longType) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   711
    __ cas_long(addr, cmp.result(), val.result(), ill, ill);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   712
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   713
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   714
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   715
  // Generate conditional move of boolean result.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   716
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   717
  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   718
           result, as_BasicType(type));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   719
  if (type == objectType) {  // Write-barrier needed for Object fields.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   720
    // Precise card mark since could either be object or array
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   721
    post_barrier(addr, val.result());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   722
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   723
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   724
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   725
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   726
void LIRGenerator::do_MathIntrinsic(Intrinsic* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   727
  switch (x->id()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   728
    case vmIntrinsics::_dabs:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   729
    case vmIntrinsics::_dsqrt: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   730
      assert(x->number_of_arguments() == 1, "wrong type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   731
      LIRItem value(x->argument_at(0), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   732
      value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   733
      LIR_Opr dst = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   734
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   735
      switch (x->id()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   736
      case vmIntrinsics::_dsqrt: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   737
        __ sqrt(value.result(), dst, LIR_OprFact::illegalOpr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   738
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   739
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   740
      case vmIntrinsics::_dabs: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   741
        __ abs(value.result(), dst, LIR_OprFact::illegalOpr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   742
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   743
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   744
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   745
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   746
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   747
    case vmIntrinsics::_dlog10: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   748
    case vmIntrinsics::_dlog: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   749
    case vmIntrinsics::_dsin: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   750
    case vmIntrinsics::_dtan: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   751
    case vmIntrinsics::_dcos: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   752
    case vmIntrinsics::_dexp: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   753
      assert(x->number_of_arguments() == 1, "wrong type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   754
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   755
      address runtime_entry = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   756
      switch (x->id()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   757
      case vmIntrinsics::_dsin:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   758
        runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   759
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   760
      case vmIntrinsics::_dcos:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   761
        runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   762
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   763
      case vmIntrinsics::_dtan:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   764
        runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   765
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   766
      case vmIntrinsics::_dlog:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   767
        runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   768
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   769
      case vmIntrinsics::_dlog10:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   770
        runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   771
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   772
      case vmIntrinsics::_dexp:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   773
        runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   774
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   775
      default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   776
        ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   777
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   778
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   779
      LIR_Opr result = call_runtime(x->argument_at(0), runtime_entry, x->type(), NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   780
      set_result(x, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   781
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   782
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   783
    case vmIntrinsics::_dpow: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   784
      assert(x->number_of_arguments() == 2, "wrong type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   785
      address runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dpow);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   786
      LIR_Opr result = call_runtime(x->argument_at(0), x->argument_at(1), runtime_entry, x->type(), NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   787
      set_result(x, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   788
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   789
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   790
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   791
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   792
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   793
void LIRGenerator::do_ArrayCopy(Intrinsic* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   794
  assert(x->number_of_arguments() == 5, "wrong type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   795
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   796
  // Copy stubs possibly call C code, e.g. G1 barriers, so we need to reserve room
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   797
  // for the C ABI (see frame::z_abi_160).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   798
  BasicTypeArray sig; // Empty signature is precise enough.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   799
  frame_map()->c_calling_convention(&sig);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   800
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   801
  // Make all state_for calls early since they can emit code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   802
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   803
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   804
  LIRItem src(x->argument_at(0), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   805
  LIRItem src_pos(x->argument_at(1), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   806
  LIRItem dst(x->argument_at(2), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   807
  LIRItem dst_pos(x->argument_at(3), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   808
  LIRItem length(x->argument_at(4), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   809
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   810
  // Operands for arraycopy must use fixed registers, otherwise
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   811
  // LinearScan will fail allocation (because arraycopy always needs a
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   812
  // call).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   813
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   814
  src.load_item_force     (FrameMap::as_oop_opr(Z_ARG1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   815
  src_pos.load_item_force (FrameMap::as_opr(Z_ARG2));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   816
  dst.load_item_force     (FrameMap::as_oop_opr(Z_ARG3));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   817
  dst_pos.load_item_force (FrameMap::as_opr(Z_ARG4));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   818
  length.load_item_force  (FrameMap::as_opr(Z_ARG5));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   819
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   820
  LIR_Opr tmp =            FrameMap::as_opr(Z_R7);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   821
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   822
  set_no_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   823
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   824
  int flags;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   825
  ciArrayKlass* expected_type;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   826
  arraycopy_helper(x, &flags, &expected_type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   827
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   828
  __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   829
               length.result(), tmp, expected_type, flags, info); // does add_safepoint
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   830
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   831
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   832
// _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   833
// _i2b, _i2c, _i2s
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   834
void LIRGenerator::do_Convert(Convert* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   835
  LIRItem value(x->value(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   836
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   837
  value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   838
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   839
  __ convert(x->op(), value.result(), reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   840
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   841
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   842
void LIRGenerator::do_NewInstance(NewInstance* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   843
  print_if_not_loaded(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   844
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   845
  // This instruction can be deoptimized in the slow path : use
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   846
  // Z_R2 as result register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   847
  const LIR_Opr reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   848
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   849
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   850
  LIR_Opr tmp1 = FrameMap::Z_R12_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   851
  LIR_Opr tmp2 = FrameMap::Z_R13_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   852
  LIR_Opr tmp3 = reg;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   853
  LIR_Opr tmp4 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   854
  LIR_Opr klass_reg = FrameMap::Z_R11_metadata_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   855
  new_instance(reg, x->klass(), x->is_unresolved(), tmp1, tmp2, tmp3, tmp4, klass_reg, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   856
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   857
  __ move(reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   858
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   859
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   860
void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   861
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   862
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   863
  LIRItem length(x->length(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   864
  length.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   865
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   866
  LIR_Opr reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   867
  LIR_Opr tmp1 = FrameMap::Z_R12_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   868
  LIR_Opr tmp2 = FrameMap::Z_R13_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   869
  LIR_Opr tmp3 = reg;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   870
  LIR_Opr tmp4 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   871
  LIR_Opr klass_reg = FrameMap::Z_R11_metadata_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   872
  LIR_Opr len = length.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   873
  BasicType elem_type = x->elt_type();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   874
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   875
  __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   876
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   877
  CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   878
  __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   879
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   880
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   881
  __ move(reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   882
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   883
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   884
void LIRGenerator::do_NewObjectArray(NewObjectArray* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   885
  // Evaluate state_for early since it may emit code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   886
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   887
  // In case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   888
  // and therefore provide the state before the parameters have been consumed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   889
  CodeEmitInfo* patching_info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   890
  if (!x->klass()->is_loaded() || PatchALot) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   891
    patching_info = state_for (x, x->state_before());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   892
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   893
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   894
  LIRItem length(x->length(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   895
  length.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   896
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   897
  const LIR_Opr reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   898
  LIR_Opr tmp1 = FrameMap::Z_R12_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   899
  LIR_Opr tmp2 = FrameMap::Z_R13_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   900
  LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   901
  LIR_Opr tmp4 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   902
  LIR_Opr klass_reg = FrameMap::Z_R11_metadata_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   903
  LIR_Opr len = length.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   904
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   905
  CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   906
  ciKlass* obj = ciObjArrayKlass::make(x->klass());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   907
  if (obj == ciEnv::unloaded_ciobjarrayklass()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   908
    BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   909
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   910
  klass2reg_with_patching(klass_reg, obj, patching_info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   911
  __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   912
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   913
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   914
  __ move(reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   915
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   916
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   917
void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   918
  Values* dims = x->dims();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   919
  int i = dims->length();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   920
  LIRItemList* items = new LIRItemList(i, i, NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   921
  while (i-- > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   922
    LIRItem* size = new LIRItem(dims->at(i), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   923
    items->at_put(i, size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   924
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   925
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   926
  // Evaluate state_for early since it may emit code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   927
  CodeEmitInfo* patching_info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   928
  if (!x->klass()->is_loaded() || PatchALot) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   929
    patching_info = state_for (x, x->state_before());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   930
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   931
    // Cannot re-use same xhandlers for multiple CodeEmitInfos, so
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   932
    // clone all handlers (NOTE: Usually this is handled transparently
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   933
    // by the CodeEmitInfo cloning logic in CodeStub constructors but
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   934
    // is done explicitly here because a stub isn't being used).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   935
    x->set_exception_handlers(new XHandlers(x->exception_handlers()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   936
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   937
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   938
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   939
  i = dims->length();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   940
  while (--i >= 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   941
    LIRItem* size = items->at(i);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   942
    size->load_nonconstant(32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   943
    // FrameMap::_reserved_argument_area_size includes the dimensions varargs, because
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   944
    // it's initialized to hir()->max_stack() when the FrameMap is created.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   945
    store_stack_parameter(size->result(), in_ByteSize(i*sizeof(jint) + FrameMap::first_available_sp_in_frame));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   946
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   947
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   948
  LIR_Opr klass_reg = FrameMap::Z_R3_metadata_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   949
  klass2reg_with_patching(klass_reg, x->klass(), patching_info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   950
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   951
  LIR_Opr rank = FrameMap::Z_R4_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   952
  __ move(LIR_OprFact::intConst(x->rank()), rank);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   953
  LIR_Opr varargs = FrameMap::Z_R5_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   954
  __ leal(LIR_OprFact::address(new LIR_Address(FrameMap::Z_SP_opr, FrameMap::first_available_sp_in_frame, T_INT)),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   955
          varargs);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   956
  LIR_OprList* args = new LIR_OprList(3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   957
  args->append(klass_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   958
  args->append(rank);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   959
  args->append(varargs);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   960
  LIR_Opr reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   961
  __ call_runtime(Runtime1::entry_for (Runtime1::new_multi_array_id),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   962
                  LIR_OprFact::illegalOpr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   963
                  reg, args, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   964
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   965
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   966
  __ move(reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   967
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   968
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   969
void LIRGenerator::do_BlockBegin(BlockBegin* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   970
  // Nothing to do.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   971
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   972
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   973
void LIRGenerator::do_CheckCast(CheckCast* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   974
  LIRItem obj(x->obj(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   975
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   976
  CodeEmitInfo* patching_info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   977
  if (!x->klass()->is_loaded() || (PatchALot && !x->is_incompatible_class_change_check())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   978
    // Must do this before locking the destination register as an oop register,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   979
    // and before the obj is loaded (the latter is for deoptimization).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   980
    patching_info = state_for (x, x->state_before());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   981
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   982
  obj.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   983
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   984
  // info for exceptions
44738
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   985
  CodeEmitInfo* info_for_exception =
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   986
      (x->needs_exception_state() ? state_for(x) :
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   987
                                    state_for(x, x->state_before(), true /*ignore_xhandler*/));
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   988
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   989
  CodeStub* stub;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   990
  if (x->is_incompatible_class_change_check()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   991
    assert(patching_info == NULL, "can't patch this");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   992
    stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
44738
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   993
  } else if (x->is_invokespecial_receiver_check()) {
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   994
    assert(patching_info == NULL, "can't patch this");
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   995
    stub = new DeoptimizeStub(info_for_exception,
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   996
                              Deoptimization::Reason_class_check,
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   997
                              Deoptimization::Action_none);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   998
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   999
    stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1000
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1001
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1002
  LIR_Opr tmp1 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1003
  LIR_Opr tmp2 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1004
  LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1005
  __ checkcast(reg, obj.result(), x->klass(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1006
               tmp1, tmp2, tmp3,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1007
               x->direct_compare(), info_for_exception, patching_info, stub,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1008
               x->profiled_method(), x->profiled_bci());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1009
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1010
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1011
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1012
void LIRGenerator::do_InstanceOf(InstanceOf* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1013
  LIRItem obj(x->obj(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1014
  CodeEmitInfo* patching_info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1015
  if (!x->klass()->is_loaded() || PatchALot) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1016
    patching_info = state_for (x, x->state_before());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1017
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1018
  // Ensure the result register is not the input register because the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1019
  // result is initialized before the patching safepoint.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1020
  obj.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1021
  LIR_Opr out_reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1022
  LIR_Opr tmp1 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1023
  LIR_Opr tmp2 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1024
  LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1025
  __ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1026
                x->direct_compare(), patching_info,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1027
                x->profiled_method(), x->profiled_bci());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1028
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1029
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1030
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1031
void LIRGenerator::do_If (If* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1032
  assert(x->number_of_sux() == 2, "inconsistency");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1033
  ValueTag tag = x->x()->type()->tag();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1034
  bool is_safepoint = x->is_safepoint();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1035
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1036
  If::Condition cond = x->cond();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1037
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1038
  LIRItem xitem(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1039
  LIRItem yitem(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1040
  LIRItem* xin = &xitem;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1041
  LIRItem* yin = &yitem;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1042
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1043
  if (tag == longTag) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1044
    // For longs, only conditions "eql", "neq", "lss", "geq" are valid;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1045
    // mirror for other conditions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1046
    if (cond == If::gtr || cond == If::leq) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1047
      cond = Instruction::mirror(cond);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1048
      xin = &yitem;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1049
      yin = &xitem;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1050
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1051
    xin->set_destroys_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1052
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1053
  xin->load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1054
  // TODO: don't load long constants != 0L
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1055
  if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && (cond == If::eql || cond == If::neq)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1056
    // inline long zero
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1057
    yin->dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1058
  } else if (tag == longTag || tag == floatTag || tag == doubleTag) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1059
    // Longs cannot handle constants at right side.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1060
    yin->load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1061
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1062
    yin->dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1063
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1064
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1065
  // Add safepoint before generating condition code so it can be recomputed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1066
  if (x->is_safepoint()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1067
    // Increment backedge counter if needed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1068
    increment_backedge_counter(state_for (x, x->state_before()), x->profiled_bci());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1069
    // Use safepoint_poll_register() instead of LIR_OprFact::illegalOpr.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1070
    __ safepoint(safepoint_poll_register(), state_for (x, x->state_before()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1071
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1072
  set_no_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1073
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1074
  LIR_Opr left = xin->result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1075
  LIR_Opr right = yin->result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1076
  __ cmp(lir_cond(cond), left, right);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1077
  // Generate branch profiling. Profiling code doesn't kill flags.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1078
  profile_branch(x, cond);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1079
  move_to_phi(x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1080
  if (x->x()->type()->is_float_kind()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1081
    __ branch(lir_cond(cond), right->type(), x->tsux(), x->usux());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1082
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1083
    __ branch(lir_cond(cond), right->type(), x->tsux());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1084
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1085
  assert(x->default_sux() == x->fsux(), "wrong destination above");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1086
  __ jump(x->default_sux());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1087
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1088
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1089
LIR_Opr LIRGenerator::getThreadPointer() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1090
  return FrameMap::as_pointer_opr(Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1091
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1092
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1093
void LIRGenerator::trace_block_entry(BlockBegin* block) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1094
  __ move(LIR_OprFact::intConst(block->block_id()), FrameMap::Z_R2_opr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1095
  LIR_OprList* args = new LIR_OprList(1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1096
  args->append(FrameMap::Z_R2_opr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1097
  address func = CAST_FROM_FN_PTR(address, Runtime1::trace_block_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1098
  __ call_runtime_leaf(func, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, args);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1099
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1100
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1101
void LIRGenerator::volatile_field_store(LIR_Opr value, LIR_Address* address,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1102
                                        CodeEmitInfo* info) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1103
  __ store(value, address, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1104
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1105
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1106
void LIRGenerator::volatile_field_load(LIR_Address* address, LIR_Opr result,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1107
                                       CodeEmitInfo* info) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1108
  __ load(address, result, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1109
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1110
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1111
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1112
void LIRGenerator::put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1113
                                     BasicType type, bool is_volatile) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1114
  LIR_Address* addr = new LIR_Address(src, offset, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1115
  bool is_obj = (type == T_ARRAY || type == T_OBJECT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1116
  if (is_obj) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1117
    // Do the pre-write barrier, if any.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1118
    pre_barrier(LIR_OprFact::address(addr), LIR_OprFact::illegalOpr /* pre_val */,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1119
                true /* do_load */, false /* patch */, NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1120
    __ move(data, addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1121
    assert(src->is_register(), "must be register");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1122
    // Seems to be a precise address.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1123
    post_barrier(LIR_OprFact::address(addr), data);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1124
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1125
    __ move(data, addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1126
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1127
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1128
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1129
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1130
void LIRGenerator::get_Object_unsafe(LIR_Opr dst, LIR_Opr src, LIR_Opr offset,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1131
                                     BasicType type, bool is_volatile) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1132
  LIR_Address* addr = new LIR_Address(src, offset, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1133
  __ load(addr, dst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1134
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1135
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1136
void LIRGenerator::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1137
  BasicType type = x->basic_type();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1138
  assert (x->is_add() && type != T_ARRAY && type != T_OBJECT, "not supported");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1139
  LIRItem src(x->object(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1140
  LIRItem off(x->offset(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1141
  LIRItem value(x->value(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1142
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1143
  src.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1144
  value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1145
  off.load_nonconstant(20);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1146
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1147
  LIR_Opr dst = rlock_result(x, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1148
  LIR_Opr data = value.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1149
  LIR_Opr offset = off.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1150
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1151
  LIR_Address* addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1152
  if (offset->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1153
    assert(Immediate::is_simm20(offset->as_jlong()), "should have been loaded into register");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1154
    addr = new LIR_Address(src.result(), offset->as_jlong(), type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1155
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1156
    addr = new LIR_Address(src.result(), offset, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1157
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1158
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1159
  __ xadd(LIR_OprFact::address(addr), data, dst, LIR_OprFact::illegalOpr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1160
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1161
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1162
void LIRGenerator::do_update_CRC32(Intrinsic* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1163
  assert(UseCRC32Intrinsics, "or should not be here");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1164
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1165
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1166
  switch (x->id()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1167
    case vmIntrinsics::_updateCRC32: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1168
      LIRItem crc(x->argument_at(0), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1169
      LIRItem val(x->argument_at(1), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1170
      // Registers destroyed by update_crc32.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1171
      crc.set_destroys_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1172
      val.set_destroys_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1173
      crc.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1174
      val.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1175
      __ update_crc32(crc.result(), val.result(), result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1176
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1177
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1178
    case vmIntrinsics::_updateBytesCRC32:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1179
    case vmIntrinsics::_updateByteBufferCRC32: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1180
      bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1181
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1182
      LIRItem crc(x->argument_at(0), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1183
      LIRItem buf(x->argument_at(1), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1184
      LIRItem off(x->argument_at(2), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1185
      LIRItem len(x->argument_at(3), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1186
      buf.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1187
      off.load_nonconstant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1188
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1189
      LIR_Opr index = off.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1190
      int offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1191
      if (off.result()->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1192
        index = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1193
        offset += off.result()->as_jint();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1194
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1195
      LIR_Opr base_op = buf.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1196
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1197
      if (index->is_valid()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1198
        LIR_Opr tmp = new_register(T_LONG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1199
        __ convert(Bytecodes::_i2l, index, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1200
        index = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1201
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1202
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1203
      LIR_Address* a = new LIR_Address(base_op, index, offset, T_BYTE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1204
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1205
      BasicTypeList signature(3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1206
      signature.append(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1207
      signature.append(T_ADDRESS);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1208
      signature.append(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1209
      CallingConvention* cc = frame_map()->c_calling_convention(&signature);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1210
      const LIR_Opr result_reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1211
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1212
      LIR_Opr arg1 = cc->at(0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1213
      LIR_Opr arg2 = cc->at(1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1214
      LIR_Opr arg3 = cc->at(2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1215
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1216
      crc.load_item_force(arg1); // We skip int->long conversion here, because CRC32 stub doesn't care about high bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1217
      __ leal(LIR_OprFact::address(a), arg2);
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1218
      len.load_item_force(arg3); // We skip int->long conversion here, because CRC32 stub expects int.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1219
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1220
      __ call_runtime_leaf(StubRoutines::updateBytesCRC32(), LIR_OprFact::illegalOpr, result_reg, cc->args());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1221
      __ move(result_reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1222
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1223
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1224
    default: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1225
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1226
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1227
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1228
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1229
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1230
void LIRGenerator::do_update_CRC32C(Intrinsic* x) {
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1231
  assert(UseCRC32CIntrinsics, "or should not be here");
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1232
  LIR_Opr result = rlock_result(x);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1233
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1234
  switch (x->id()) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1235
    case vmIntrinsics::_updateBytesCRC32C:
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1236
    case vmIntrinsics::_updateDirectByteBufferCRC32C: {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1237
      bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32C);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1238
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1239
      LIRItem crc(x->argument_at(0), this);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1240
      LIRItem buf(x->argument_at(1), this);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1241
      LIRItem off(x->argument_at(2), this);
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1242
      LIRItem end(x->argument_at(3), this);
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1243
      buf.load_item();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1244
      off.load_nonconstant();
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1245
      end.load_nonconstant();
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1246
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1247
      // len = end - off
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1248
      LIR_Opr len  = end.result();
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1249
      LIR_Opr tmpA = new_register(T_INT);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1250
      LIR_Opr tmpB = new_register(T_INT);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1251
      __ move(end.result(), tmpA);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1252
      __ move(off.result(), tmpB);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1253
      __ sub(tmpA, tmpB, tmpA);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1254
      len = tmpA;
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1255
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1256
      LIR_Opr index = off.result();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1257
      int offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0;
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1258
      if (off.result()->is_constant()) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1259
        index = LIR_OprFact::illegalOpr;
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1260
        offset += off.result()->as_jint();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1261
      }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1262
      LIR_Opr base_op = buf.result();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1263
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1264
      if (index->is_valid()) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1265
        LIR_Opr tmp = new_register(T_LONG);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1266
        __ convert(Bytecodes::_i2l, index, tmp);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1267
        index = tmp;
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1268
      }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1269
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1270
      LIR_Address* a = new LIR_Address(base_op, index, offset, T_BYTE);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1271
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1272
      BasicTypeList signature(3);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1273
      signature.append(T_INT);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1274
      signature.append(T_ADDRESS);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1275
      signature.append(T_INT);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1276
      CallingConvention* cc = frame_map()->c_calling_convention(&signature);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1277
      const LIR_Opr result_reg = result_register_for (x->type());
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1278
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1279
      LIR_Opr arg1 = cc->at(0);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1280
      LIR_Opr arg2 = cc->at(1);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1281
      LIR_Opr arg3 = cc->at(2);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1282
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1283
      crc.load_item_force(arg1); // We skip int->long conversion here, because CRC32C stub doesn't care about high bits.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1284
      __ leal(LIR_OprFact::address(a), arg2);
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1285
      __ move(len, cc->at(2));   // We skip int->long conversion here, because CRC32C stub expects int.
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1286
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1287
      __ call_runtime_leaf(StubRoutines::updateBytesCRC32C(), LIR_OprFact::illegalOpr, result_reg, cc->args());
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1288
      __ move(result_reg, result);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1289
      break;
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1290
    }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1291
    default: {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1292
      ShouldNotReachHere();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1293
    }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1294
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1295
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1296
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1297
void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
42897
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1298
  assert(x->number_of_arguments() == 3, "wrong type");
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1299
  assert(UseFMA, "Needs FMA instructions support.");
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1300
  LIRItem value(x->argument_at(0), this);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1301
  LIRItem value1(x->argument_at(1), this);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1302
  LIRItem value2(x->argument_at(2), this);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1303
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1304
  value2.set_destroys_register();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1305
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1306
  value.load_item();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1307
  value1.load_item();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1308
  value2.load_item();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1309
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1310
  LIR_Opr calc_input = value.result();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1311
  LIR_Opr calc_input1 = value1.result();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1312
  LIR_Opr calc_input2 = value2.result();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1313
  LIR_Opr calc_result = rlock_result(x);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1314
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1315
  switch (x->id()) {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1316
  case vmIntrinsics::_fmaD:   __ fmad(calc_input, calc_input1, calc_input2, calc_result); break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1317
  case vmIntrinsics::_fmaF:   __ fmaf(calc_input, calc_input1, calc_input2, calc_result); break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1318
  default:                    ShouldNotReachHere();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1319
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1320
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1321
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1322
void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1323
  fatal("vectorizedMismatch intrinsic is not implemented on this platform");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1324
}