src/hotspot/cpu/s390/compiledIC_s390.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58505 c16f3a24a6fc
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
58505
c16f3a24a6fc 8225681: vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine fails due a) MT-unsafe modification of inline cache
coleenp
parents: 57583
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
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/macroAssembler.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "code/compiledIC.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "code/icBuffer.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "code/nmethod.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "memory/resourceArea.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "runtime/mutexLocker.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "runtime/safepoint.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#ifdef COMPILER2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
#include "opto/matcher.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
// ----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
#undef  __
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
#define __ _masm.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark/* = NULL*/) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
#ifdef COMPILER2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
  // Stub is fixed up when the corresponding call is converted from calling
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
  // compiled code to calling interpreted code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
  if (mark == NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
    // Get the mark within main instrs section which is set to the address of the call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
    mark = cbuf.insts_mark();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
  assert(mark != NULL, "mark must not be NULL");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
  // Note that the code buffer's insts_mark is always relative to insts.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
  // That's why we must use the macroassembler to generate a stub.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
  MacroAssembler _masm(&cbuf);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
  address stub = __ start_a_stub(Compile::MAX_stubs_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
  if (stub == NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
    return NULL;  // CodeBuffer::expand failed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
  __ relocate(static_stub_Relocation::spec(mark));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
  AddressLiteral meta = __ allocate_metadata_address(NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
  bool success = __ load_const_from_toc(as_Register(Matcher::inline_cache_reg_encode()), meta);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
  __ set_inst_mark();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
  AddressLiteral a((address)-1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
  success = success && __ load_const_from_toc(Z_R1, a);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
  if (!success) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
    return NULL;  // CodeCache is full.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
  __ z_br(Z_R1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
  __ end_a_stub(); // Update current stubs pointer and restore insts_end.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
  return stub;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
#else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
  ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
#endif
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
#undef __
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
int CompiledStaticCall::to_interp_stub_size() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
  return 2 * MacroAssembler::load_const_from_toc_size() +
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
         2; // branch
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
// Relocation entries for call stub, compiled java to interpreter.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
int CompiledStaticCall::reloc_to_interp_stub() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
  return 5; // 4 in emit_java_to_interp + 1 in Java_Static_Call
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
    93
void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, address entry) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
    94
  address stub = find_stub(/*is_aot*/ false);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
  guarantee(stub != NULL, "stub not found");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
  if (TraceICs) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
    ResourceMark rm;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
    99
    tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
                  p2i(instruction_address()),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
                  callee->name_and_sig_as_C_string());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
  // Creation also verifies the object.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   105
  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + NativeCall::get_IC_pos_in_java_to_interp_stub());
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
  NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
58505
c16f3a24a6fc 8225681: vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine fails due a) MT-unsafe modification of inline cache
coleenp
parents: 57583
diff changeset
   107
  verify_mt_safe(callee, entry, method_holder, jump);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
  // Update stub.
57583
aad50831e169 8228618: s390: c1/c2 fail to add a metadata relocation in the static call stub.
rrich
parents: 52384
diff changeset
   110
  method_holder->set_data((intptr_t)callee(), relocInfo::metadata_type);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
  jump->set_jump_destination(entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
  // Update jump to call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
  set_destination_mt_safe(stub);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   117
void CompiledDirectStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
  // Reset stub.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
  address stub = static_stub->addr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
  assert(stub != NULL, "stub not found");
52384
d6dc479bcdd3 8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents: 51996
diff changeset
   121
  assert(CompiledICLocker::is_safe(stub), "mt unsafe call");
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
  // Creation also verifies the object.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   123
  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + NativeCall::get_IC_pos_in_java_to_interp_stub());
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
  NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
57583
aad50831e169 8228618: s390: c1/c2 fail to add a metadata relocation in the static call stub.
rrich
parents: 52384
diff changeset
   125
  method_holder->set_data(0, relocInfo::metadata_type);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
  jump->set_jump_destination((address)-1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
//-----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
#ifndef PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   133
void CompiledDirectStaticCall::verify() {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
  // Verify call.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   135
  _call->verify();
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 47216
diff changeset
   136
  _call->verify_alignment();
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
  // Verify stub.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   139
  address stub = find_stub(/*is_aot*/ false);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
  assert(stub != NULL, "no stub found for static call");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
  // Creation also verifies the object.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   142
  NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + NativeCall::get_IC_pos_in_java_to_interp_stub());
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
  NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   144
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
  // Verify state.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   146
  assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
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
#endif // !PRODUCT