src/hotspot/cpu/s390/macroAssembler_s390.inline.hpp
author vlivanov
Wed, 24 Jul 2019 10:50:40 +0300
changeset 57574 6a159c6c23cc
parent 53244 9807daeb47c4
permissions -rw-r--r--
8227260: JNI upcalls should bypass class initialization barrier in c2i adapter Reviewed-by: eosterlund, dholmes, mdoerr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     3
 * Copyright (c) 2016 SAP SE. All rights reserved.
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    26
#ifndef CPU_S390_MACROASSEMBLER_S390_INLINE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    27
#define CPU_S390_MACROASSEMBLER_S390_INLINE_HPP
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "asm/assembler.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "asm/macroAssembler.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "asm/codeBuffer.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "code/codeCache.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "runtime/thread.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
// Simplified shift operations for single register operands, constant shift amount.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
inline void MacroAssembler::lshift(Register r, int places, bool is_DW) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
  if (is_DW) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
    z_sllg(r, r, places);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
    z_sll(r, places);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
inline void MacroAssembler::rshift(Register r, int places, bool is_DW) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
  if (is_DW) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
    z_srlg(r, r, places);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
    z_srl(r, places);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
  }
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
// *((int8_t*)(dst)) |= imm8
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
inline void MacroAssembler::or2mem_8(Address& dst, int64_t imm8) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
  if (Displacement::is_shortDisp(dst.disp())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
    z_oi(dst, imm8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
    z_oiy(dst, imm8);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
inline int MacroAssembler::store_const(const Address &dest, long imm, Register scratch, bool is_long) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
  unsigned int lm = is_long ? 8 : 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
  unsigned int lc = is_long ? 8 : 4;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
  return store_const(dest, imm, lm, lc, scratch);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
// Do not rely on add2reg* emitter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
// Depending on CmdLine switches and actual parameter values,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
// the generated code may alter the condition code, which is counter-intuitive
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
// to the semantics of the "load address" (LA/LAY) instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
// Generic address loading d <- base(a) + index(a) + disp(a)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
inline void MacroAssembler::load_address(Register d, const Address &a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
  if (Displacement::is_shortDisp(a.disp())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
    z_la(d, a.disp(), a.indexOrR0(), a.baseOrR0());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
  } else if (Displacement::is_validDisp(a.disp())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
    z_lay(d, a.disp(), a.indexOrR0(), a.baseOrR0());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
    guarantee(false, "displacement = " SIZE_FORMAT_HEX ", out of range for LA/LAY", a.disp());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
inline void MacroAssembler::load_const(Register t, void* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
  load_const(t, (long)x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
// Load a 64 bit constant encoded by a `Label'.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
// Works for bound as well as unbound labels. For unbound labels, the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
// code will become patched as soon as the label gets bound.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
inline void MacroAssembler::load_const(Register t, Label& L) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
  load_const(t, target(L));
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
inline void MacroAssembler::load_const(Register t, const AddressLiteral& a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
  assert(t != Z_R0, "R0 not allowed");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
  // First relocate (we don't change the offset in the RelocationHolder,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
  // just pass a.rspec()), then delegate to load_const(Register, long).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
  relocate(a.rspec());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
  load_const(t, (long)a.value());
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
inline void MacroAssembler::load_const_optimized(Register t, long x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
  (void) load_const_optimized_rtn_len(t, x, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
inline void MacroAssembler::load_const_optimized(Register t, void* a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
  load_const_optimized(t, (long)a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
inline void MacroAssembler::load_const_optimized(Register t, Label& L) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
  load_const_optimized(t, target(L));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
inline void MacroAssembler::load_const_optimized(Register t, const AddressLiteral& a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
  assert(t != Z_R0, "R0 not allowed");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
  assert((relocInfo::relocType)a.rspec().reloc()->type() == relocInfo::none,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
          "cannot relocate optimized load_consts");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
  load_const_optimized(t, a.value());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
inline void MacroAssembler::set_oop(jobject obj, Register d) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
  load_const(d, allocate_oop_address(obj));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
inline void MacroAssembler::set_oop_constant(jobject obj, Register d) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
  load_const(d, constant_oop_address(obj));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
// Adds MetaData constant md to TOC and loads it from there.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
// md is added to the oop_recorder, but no relocation is added.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
inline bool MacroAssembler::set_metadata_constant(Metadata* md, Register d) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
  AddressLiteral a = constant_metadata_address(md);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
  return load_const_from_toc(d, a, d); // Discards the relocation.
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
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
inline bool MacroAssembler::is_call_pcrelative_short(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
  return is_equal(inst, BRAS_ZOPC); // off 16, len 16
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
inline bool MacroAssembler::is_call_pcrelative_long(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
  return is_equal(inst, BRASL_ZOPC); // off 16, len 32
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
inline bool MacroAssembler::is_branch_pcrelative_short(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
  // Branch relative, 16-bit offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
  return is_equal(inst, BRC_ZOPC); // off 16, len 16
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   147
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   148
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   149
inline bool MacroAssembler::is_branch_pcrelative_long(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   150
  // Branch relative, 32-bit offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
  return is_equal(inst, BRCL_ZOPC); // off 16, len 32
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   152
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   153
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   154
inline bool MacroAssembler::is_compareandbranch_pcrelative_short(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
  // Compare and branch relative, 16-bit offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
  return is_equal(inst, CRJ_ZOPC, CMPBRANCH_MASK)  || is_equal(inst, CGRJ_ZOPC, CMPBRANCH_MASK)  ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
         is_equal(inst, CIJ_ZOPC, CMPBRANCH_MASK)  || is_equal(inst, CGIJ_ZOPC, CMPBRANCH_MASK)  ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
         is_equal(inst, CLRJ_ZOPC, CMPBRANCH_MASK) || is_equal(inst, CLGRJ_ZOPC, CMPBRANCH_MASK) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   159
         is_equal(inst, CLIJ_ZOPC, CMPBRANCH_MASK) || is_equal(inst, CLGIJ_ZOPC, CMPBRANCH_MASK);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   160
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   161
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   162
inline bool MacroAssembler::is_branchoncount_pcrelative_short(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   163
  // Branch relative on count, 16-bit offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   164
  return is_equal(inst, BRCT_ZOPC) || is_equal(inst, BRCTG_ZOPC); // off 16, len 16
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   165
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   166
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   167
inline bool MacroAssembler::is_branchonindex32_pcrelative_short(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   168
  // Branch relative on index (32bit), 16-bit offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   169
  return is_equal(inst, BRXH_ZOPC) || is_equal(inst, BRXLE_ZOPC); // off 16, len 16
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   170
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   171
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   172
inline bool MacroAssembler::is_branchonindex64_pcrelative_short(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   173
  // Branch relative on index (64bit), 16-bit offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   174
  return is_equal(inst, BRXHG_ZOPC) || is_equal(inst, BRXLG_ZOPC); // off 16, len 16
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   175
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   176
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   177
inline bool MacroAssembler::is_branchonindex_pcrelative_short(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   178
  return is_branchonindex32_pcrelative_short(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   179
         is_branchonindex64_pcrelative_short(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   180
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   181
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   182
inline bool MacroAssembler::is_branch_pcrelative16(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   183
  return is_branch_pcrelative_short(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   184
         is_compareandbranch_pcrelative_short(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   185
         is_branchoncount_pcrelative_short(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   186
         is_branchonindex_pcrelative_short(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   187
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   188
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   189
inline bool MacroAssembler::is_branch_pcrelative32(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   190
  return is_branch_pcrelative_long(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   191
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   192
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   193
inline bool MacroAssembler::is_branch_pcrelative(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   194
  return is_branch_pcrelative16(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   195
         is_branch_pcrelative32(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   196
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   197
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   198
inline bool MacroAssembler::is_load_pcrelative_long(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   199
  // Load relative, 32-bit offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   200
  return is_equal(inst, LRL_ZOPC, REL_LONG_MASK) || is_equal(inst, LGRL_ZOPC, REL_LONG_MASK); // off 16, len 32
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   201
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   202
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   203
inline bool MacroAssembler::is_misc_pcrelative_long(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   204
  // Load address, execute relative, 32-bit offset.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   205
  return is_equal(inst, LARL_ZOPC, REL_LONG_MASK) || is_equal(inst, EXRL_ZOPC, REL_LONG_MASK); // off 16, len 32
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
inline bool MacroAssembler::is_pcrelative_short(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   209
  return is_branch_pcrelative16(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   210
         is_call_pcrelative_short(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   211
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   212
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   213
inline bool MacroAssembler::is_pcrelative_long(unsigned long inst) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   214
  return is_branch_pcrelative32(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   215
         is_call_pcrelative_long(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   216
         is_load_pcrelative_long(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   217
         is_misc_pcrelative_long(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   218
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   219
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   220
inline bool MacroAssembler::is_load_pcrelative_long(address iLoc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   221
  unsigned long inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   222
  unsigned int  len = get_instruction(iLoc, &inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   223
  return (len == 6) && is_load_pcrelative_long(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   224
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   225
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   226
inline bool MacroAssembler::is_pcrelative_short(address iLoc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   227
  unsigned long inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   228
  unsigned int  len = get_instruction(iLoc, &inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   229
  return ((len == 4) || (len == 6)) && is_pcrelative_short(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   230
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   231
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   232
inline bool MacroAssembler::is_pcrelative_long(address iLoc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   233
  unsigned long inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   234
  unsigned int  len = get_instruction(iLoc, &inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   235
  return (len == 6) && is_pcrelative_long(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   236
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   237
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   238
// Dynamic TOC. Test for any pc-relative instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   239
inline bool MacroAssembler::is_pcrelative_instruction(address iloc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   240
  unsigned long inst;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   241
  get_instruction(iloc, &inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   242
  return is_pcrelative_short(inst) ||
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   243
         is_pcrelative_long(inst);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   244
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   245
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   246
inline bool MacroAssembler::is_load_addr_pcrel(address a) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   247
  return is_equal(a, LARL_ZOPC, LARL_MASK);
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
// Save the return pc in the register that should be stored as the return pc
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   251
// in the current frame (default is R14).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   252
inline void MacroAssembler::save_return_pc(Register pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   253
  z_stg(pc, _z_abi16(return_pc), Z_SP);
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
inline void MacroAssembler::restore_return_pc() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   257
  z_lg(Z_R14, _z_abi16(return_pc), Z_SP);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   258
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   259
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   260
// Call a function with given entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   261
inline address MacroAssembler::call(Register function_entry) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   262
  assert(function_entry != Z_R0, "function_entry cannot be Z_R0");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   263
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   264
  Assembler::z_basr(Z_R14, function_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   265
  _last_calls_return_pc = pc();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   266
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   267
  return _last_calls_return_pc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   268
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   269
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   270
// Call a C function via a function entry.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   271
inline address MacroAssembler::call_c(Register function_entry) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   272
  return call(function_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   273
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   274
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   275
// Call a stub function via a function descriptor, but don't save TOC before
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   276
// call, don't setup TOC and ENV for call, and don't restore TOC after call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   277
inline address MacroAssembler::call_stub(Register function_entry) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   278
  return call_c(function_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   279
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   280
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   281
inline address MacroAssembler::call_stub(address function_entry) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   282
  return call_c(function_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   283
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   284
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   285
// Get the pc where the last emitted call will return to.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   286
inline address MacroAssembler::last_calls_return_pc() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   287
  return _last_calls_return_pc;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   288
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   289
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   290
inline void MacroAssembler::set_last_Java_frame(Register last_Java_sp, Register last_Java_pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   291
  set_last_Java_frame(last_Java_sp, last_Java_pc, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   292
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   293
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   294
inline void MacroAssembler::set_last_Java_frame_static(Register last_Java_sp, Register last_Java_pc) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   295
  set_last_Java_frame(last_Java_sp, last_Java_pc, false);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   296
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   297
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   298
inline void MacroAssembler::reset_last_Java_frame(void) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   299
  reset_last_Java_frame(true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   300
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   301
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   302
inline void MacroAssembler::reset_last_Java_frame_static(void) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   303
  reset_last_Java_frame(false);
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
inline void MacroAssembler::set_top_ijava_frame_at_SP_as_last_Java_frame(Register sp, Register tmp1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   307
  set_top_ijava_frame_at_SP_as_last_Java_frame(sp, tmp1, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   308
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   309
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   310
inline void MacroAssembler::set_top_ijava_frame_at_SP_as_last_Java_frame_static(Register sp, Register tmp1) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   311
  set_top_ijava_frame_at_SP_as_last_Java_frame(sp, tmp1, true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   312
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   313
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
   314
#endif // CPU_S390_MACROASSEMBLER_S390_INLINE_HPP