hotspot/src/cpu/ppc/vm/relocInfo_ppc.cpp
author goetz
Wed, 15 Apr 2015 12:44:56 +0200
changeset 30303 c703c89fddbf
parent 22829 08b62d0e80ed
child 31849 92ca49fa9fa7
permissions -rw-r--r--
8077838: Recent developments for ppc. Summary: Power 8 recognition and instructions, math.*Exact intrinsics and rtm, C2 optimizations Reviewed-by: kvn, simonis
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     1
/*
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 22829
diff changeset
     2
 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 22829
diff changeset
     3
 * Copyright 2012, 2015 SAP AG. All rights reserved.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     5
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     9
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    14
 * accompanied this code).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    15
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    19
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    22
 * questions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    23
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    24
 */
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    25
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    27
#include "asm/assembler.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    28
#include "code/relocInfo.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    29
#include "nativeInst_ppc.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    30
#include "oops/oop.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    31
#include "runtime/safepoint.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    32
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    33
void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    34
  // The following comment is from the declaration of DataRelocation:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    35
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    36
  //  "The "o" (displacement) argument is relevant only to split relocations
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    37
  //   on RISC machines.  In some CPUs (SPARC), the set-hi and set-lo ins'ns
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    38
  //   can encode more than 32 bits between them.  This allows compilers to
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    39
  //   share set-hi instructions between addresses that differ by a small
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    40
  //   offset (e.g., different static variables in the same class).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    41
  //   On such machines, the "x" argument to set_value on all set-lo
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    42
  //   instructions must be the same as the "x" argument for the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    43
  //   corresponding set-hi instructions.  The "o" arguments for the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    44
  //   set-hi instructions are ignored, and must not affect the high-half
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    45
  //   immediate constant.  The "o" arguments for the set-lo instructions are
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    46
  //   added into the low-half immediate constant, and must not overflow it."
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    47
  //
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    48
  // Currently we don't support splitting of relocations, so o must be
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    49
  // zero:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    50
  assert(o == 0, "tried to split relocations");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    51
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    52
  if (!verify_only) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    53
    if (format() != 1) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    54
      nativeMovConstReg_at(addr())->set_data_plain(((intptr_t)x), code());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    55
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    56
      assert(type() == relocInfo::oop_type || type() == relocInfo::metadata_type,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    57
             "how to encode else?");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    58
      narrowOop no = (type() == relocInfo::oop_type) ?
22829
08b62d0e80ed 8024379: Adapt PPC64 port to 8003424
goetz
parents: 22824
diff changeset
    59
        oopDesc::encode_heap_oop((oop)x) : Klass::encode_klass((Klass*)x);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    60
      nativeMovConstReg_at(addr())->set_narrow_oop(no, code());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    61
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    62
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    63
    assert((address) (nativeMovConstReg_at(addr())->data()) == x, "data must match");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    64
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    65
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    66
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    67
address Relocation::pd_call_destination(address orig_addr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    68
  intptr_t adj = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    69
  address inst_loc = addr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    70
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    71
  if (orig_addr != NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    72
    // We just moved this call instruction from orig_addr to addr().
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    73
    // This means its target will appear to have grown by addr() - orig_addr.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    74
    adj = -(inst_loc - orig_addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    75
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    76
  if (NativeFarCall::is_far_call_at(inst_loc)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    77
    NativeFarCall* call = nativeFarCall_at(inst_loc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    78
    return call->destination() + (intptr_t)(call->is_pcrelative() ? adj : 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    79
  } else if (NativeJump::is_jump_at(inst_loc)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    80
    NativeJump* jump = nativeJump_at(inst_loc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    81
    return jump->jump_destination() + (intptr_t)(jump->is_pcrelative() ? adj : 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    82
  } else if (NativeConditionalFarBranch::is_conditional_far_branch_at(inst_loc)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    83
    NativeConditionalFarBranch* branch = NativeConditionalFarBranch_at(inst_loc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    84
    return branch->branch_destination();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    85
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    86
    // There are two instructions at the beginning of a stub, therefore we
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    87
    // load at orig_addr + 8.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    88
    orig_addr = nativeCall_at(inst_loc)->get_trampoline();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    89
    if (orig_addr == NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    90
      return (address) -1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    91
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    92
      return (address) nativeMovConstReg_at(orig_addr + 8)->data();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    93
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    94
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    95
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    96
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    97
void Relocation::pd_set_call_destination(address x) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    98
  address inst_loc = addr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    99
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   100
  if (NativeFarCall::is_far_call_at(inst_loc)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   101
    NativeFarCall* call = nativeFarCall_at(inst_loc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   102
    call->set_destination(x);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   103
  } else if (NativeJump::is_jump_at(inst_loc)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   104
    NativeJump* jump= nativeJump_at(inst_loc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   105
    jump->set_jump_destination(x);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   106
  } else if (NativeConditionalFarBranch::is_conditional_far_branch_at(inst_loc)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   107
    NativeConditionalFarBranch* branch = NativeConditionalFarBranch_at(inst_loc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   108
    branch->set_branch_destination(x);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   109
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   110
    NativeCall* call = nativeCall_at(inst_loc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   111
    call->set_destination_mt_safe(x, false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   112
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   113
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   114
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   115
address* Relocation::pd_address_in_code() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   116
  ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   117
  return 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   118
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   119
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   120
address Relocation::pd_get_address_from_code() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   121
  return (address)(nativeMovConstReg_at(addr())->data());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   122
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   123
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   124
void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   125
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   126
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   127
void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   128
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   129
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   130
void metadata_Relocation::pd_fix_value(address x) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   131
}