hotspot/src/cpu/s390/vm/compiledIC_s390.cpp
author redestad
Mon, 03 Jul 2017 09:01:34 +0200
changeset 46608 b0da00b77053
parent 42650 1f304d0c888b
child 46953 39063b484ec2
permissions -rw-r--r--
8183232: Avoid resolving method_kind in AbstractInterpreter::can_be_compiled Reviewed-by: coleenp, mdoerr, neliasso
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/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());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
  // A generated lambda form might be deleted from the Lambdaform
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
  // cache in MethodTypeForm.  If a jit compiled lambdaform method
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
  // becomes not entrant and the cache access returns null, the new
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
  // resolve will lead to a new generated LambdaForm.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
  assert(method_holder->data() == 0 || method_holder->data() == (intptr_t)callee() || callee->is_compiled_lambda_form(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
         "a) MT-unsafe modification of inline cache");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
  assert(jump->jump_destination() == (address)-1 || jump->jump_destination() == entry,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
         "b) MT-unsafe modification of inline cache");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
  // Update stub.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
  method_holder->set_data((intptr_t)callee());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
  jump->set_jump_destination(entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
  // Update jump to call.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
  set_destination_mt_safe(stub);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   126
void CompiledDirectStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
  assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
  // Reset stub.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
  address stub = static_stub->addr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
  assert(stub != NULL, "stub not found");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
  // Creation also verifies the object.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   132
  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
   133
  NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
  method_holder->set_data(0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
  jump->set_jump_destination((address)-1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
//-----------------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
#ifndef PRODUCT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   142
void CompiledDirectStaticCall::verify() {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   143
  // Verify call.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   144
  _call->verify();
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   145
  if (os::is_MP()) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   146
    _call->verify_alignment();
42065
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
  // Verify stub.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   150
  address stub = find_stub(/*is_aot*/ false);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
  assert(stub != NULL, "no stub found for static call");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   152
  // Creation also verifies the object.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42065
diff changeset
   153
  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
   154
  NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
  // Verify state.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
  assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   159
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   160
#endif // !PRODUCT