src/hotspot/cpu/s390/relocInfo_s390.cpp
author herrick
Thu, 17 Oct 2019 07:55:35 -0400
branchJDK-8200758-branch
changeset 58670 6fb9e12d5595
parent 57583 aad50831e169
permissions -rw-r--r--
8232280: close() is not called on return value of Files.walk() Reviewed-by: asemenyuk, asemenuk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
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
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 "asm/assembler.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "code/relocInfo.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "nativeInst_s390.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "oops/oop.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "runtime/safepoint.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
  // we don't support splitting of relocations, so o must be zero:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
  assert(o == 0, "tried to split relocations");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
  if (!verify_only) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
    switch (format()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
      case relocInfo::uncompressed_format:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
        nativeMovConstReg_at(addr())->set_data_plain(((intptr_t)x) + o, code());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
      case relocInfo::compressed_format:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
        if (type() == relocInfo::metadata_type)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
          nativeMovConstReg_at(addr())->set_narrow_klass(((intptr_t)x) + o);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
        else if (type() == relocInfo::oop_type)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
          nativeMovConstReg_at(addr())->set_narrow_oop(((intptr_t)x) + o);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
        else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
          guarantee(false, "bad relocInfo type for relocInfo::narrow_oop_format");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
      case relocInfo::pcrel_addr_format:  // patch target location
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
        nativeMovConstReg_at(addr())->set_pcrel_addr(((intptr_t)x) + o, code());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
      case relocInfo::pcrel_data_format:  // patch data at target location
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
        nativeMovConstReg_at(addr())->set_pcrel_data(((intptr_t)x) + o, code());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
      default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
        assert(false, "not a valid relocInfo format");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
    // TODO: Reading of narrow oops out of code stream is not implemented
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
    // (see nativeMovConstReg::data()). Implement this if you want to verify.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
    // assert(x == (address) nativeMovConstReg_at(addr())->data(), "Instructions must match");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
    switch (format()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
      case relocInfo::uncompressed_format:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
      case relocInfo::compressed_format:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
      case relocInfo::pcrel_addr_format:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
      case relocInfo::pcrel_data_format:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
      default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
        assert(false, "not a valid relocInfo format");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
address Relocation::pd_call_destination(address orig_addr) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
  address   inst_addr = addr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
  if (NativeFarCall::is_far_call_at(inst_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
    if (!ShortenBranches) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
      if (MacroAssembler::is_call_far_pcrelative(inst_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
        address a1 = MacroAssembler::get_target_addr_pcrel(orig_addr+MacroAssembler::nop_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
        address a2 = MacroAssembler::get_target_addr_pcrel(inst_addr+MacroAssembler::nop_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
        address a3 = nativeFarCall_at(orig_addr)->destination();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
        address a4 = nativeFarCall_at(inst_addr)->destination();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
        if ((a1 != a3) || (a2 != a4)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
          unsigned int range = 128;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
          Assembler::dump_code_range(tty, inst_addr, range, "pc-relative call w/o ShortenBranches?");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
          Assembler::dump_code_range(tty, orig_addr, range, "pc-relative call w/o ShortenBranches?");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
          assert(false, "pc-relative call w/o ShortenBranches?");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
        return a1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
      return (address)(-1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
    NativeFarCall* call;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
    if (orig_addr == NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
      call = nativeFarCall_at(inst_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
    } else {
42556
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   105
      // must access location (in CP) where destination is stored in unmoved code, because load from CP is pc-relative
c03d98321ad1 8169317: [s390] Various minor bug fixes and adaptions.
goetz
parents: 42065
diff changeset
   106
      call = nativeFarCall_at(orig_addr);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
    return call->destination();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
  if (NativeCall::is_call_at(inst_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
    NativeCall* call = nativeCall_at(inst_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
    if (call->is_pcrelative()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
      intptr_t off = inst_addr - orig_addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
      return (address) (call->destination()-off);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
  return (address) nativeMovConstReg_at(inst_addr)->data();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
void Relocation::pd_set_call_destination(address x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
  address inst_addr = addr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
  if (NativeFarCall::is_far_call_at(inst_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
    if (!ShortenBranches) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
      if (MacroAssembler::is_call_far_pcrelative(inst_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
        address a1 = MacroAssembler::get_target_addr_pcrel(inst_addr+MacroAssembler::nop_size());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
        address a3 = nativeFarCall_at(inst_addr)->destination();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
        if (a1 != a3) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
          unsigned int range = 128;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
          Assembler::dump_code_range(tty, inst_addr, range, "pc-relative call w/o ShortenBranches?");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
          assert(false, "pc-relative call w/o ShortenBranches?");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
        nativeFarCall_at(inst_addr)->set_destination(x, 0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
        return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
      assert(x == (address)-1, "consistency check");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
    int toc_offset = -1;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
    if (type() == relocInfo::runtime_call_w_cp_type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
      toc_offset = ((runtime_call_w_cp_Relocation *)this)->get_constant_pool_offset();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   147
    if (toc_offset>=0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   148
      NativeFarCall* call = nativeFarCall_at(inst_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   149
      call->set_destination(x, toc_offset);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   150
      return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
    }
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
  if (NativeCall::is_call_at(inst_addr)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
    NativeCall* call = nativeCall_at(inst_addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
    if (call->is_pcrelative()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
      call->set_destination_mt_safe(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
      return;
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
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   162
  // constant is absolute, must use x
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   163
  nativeMovConstReg_at(inst_addr)->set_data(((intptr_t)x));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   164
}
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
address* Relocation::pd_address_in_code() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   168
 ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   169
 return 0;
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
address Relocation::pd_get_address_from_code() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   173
   return  (address) (nativeMovConstReg_at(addr())->data());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   174
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   175
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   176
void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   177
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   178
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   179
void metadata_Relocation::pd_fix_value(address x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   180
}