src/hotspot/cpu/x86/compiledIC_aot_x86_64.cpp
author eosterlund
Thu, 01 Nov 2018 14:57:26 +0100
changeset 52384 d6dc479bcdd3
parent 47216 71c04702a3d5
permissions -rw-r--r--
8212681: Refactor IC locking to use a fine grained CompiledICLocker Reviewed-by: coleenp, rehn, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     1
/*
52384
d6dc479bcdd3 8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents: 47216
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     4
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     8
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    13
 * accompanied this code).
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    14
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    18
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    21
 * questions.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    22
 */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    23
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42650
diff changeset
    24
#include "precompiled.hpp"
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42650
diff changeset
    25
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    26
#include "aot/compiledIC_aot.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    27
#include "code/codeCache.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    28
#include "memory/resourceArea.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    29
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    30
void CompiledDirectStaticCall::set_to_far(const methodHandle& callee, address entry) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    31
  address stub = find_stub(true /* is_far */);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    32
  guarantee(stub != NULL, "stub not found");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    33
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    34
  if (TraceICs) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    35
    ResourceMark rm;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    36
    tty->print_cr("CompiledDirectStaticCall@" INTPTR_FORMAT ": set_to_far %s",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    37
                  p2i(instruction_address()),
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    38
                  callee->name_and_sig_as_C_string());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    39
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    40
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    41
  // Creation also verifies the object.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    42
  // mov rax,imm_aot_addr
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    43
  // jmp rax
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    44
  NativeMovConstReg* destination_holder = nativeMovConstReg_at(stub);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    45
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    46
#ifdef ASSERT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    47
  // read the value once
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    48
  intptr_t data = destination_holder->data();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    49
  assert(data == 0 || data == (intptr_t)entry,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    50
         "MT-unsafe modification of inline cache");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    51
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    52
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    53
  // Update stub.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    54
  destination_holder->set_data((intptr_t)entry);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    55
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    56
  // Update jump to call.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    57
  set_destination_mt_safe(stub);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    58
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    59
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    60
void CompiledPltStaticCall::set_to_interpreted(const methodHandle& callee, address entry) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    61
  address stub = find_stub();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    62
  guarantee(stub != NULL, "stub not found");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    63
  if (TraceICs) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    64
    ResourceMark rm;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    65
    tty->print_cr("CompiledPltStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    66
                  p2i(instruction_address()),
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    67
                  callee->name_and_sig_as_C_string());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    68
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    69
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    70
  // Creation also verifies the object.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    71
  NativeLoadGot* method_loader = nativeLoadGot_at(stub);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    72
  NativeGotJump* jump          = nativeGotJump_at(method_loader->next_instruction_address());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    73
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    74
  intptr_t data = method_loader->data();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    75
  address destination = jump->destination();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    76
  assert(data == 0 || data == (intptr_t)callee(),
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    77
         "a) MT-unsafe modification of inline cache");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    78
  assert(destination == (address)-1 || destination == entry,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    79
         "b) MT-unsafe modification of inline cache");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    80
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    81
  // Update stub.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    82
  method_loader->set_data((intptr_t)callee());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    83
  jump->set_jump_destination(entry);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    84
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    85
  // Update jump to call.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    86
  set_destination_mt_safe(stub);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    87
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    88
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    89
#ifdef NEVER_CALLED
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    90
void CompiledPltStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    91
  // Reset stub.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    92
  address stub = static_stub->addr();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    93
  assert(stub != NULL, "stub not found");
52384
d6dc479bcdd3 8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents: 47216
diff changeset
    94
  assert(CompiledICLocker::is_safe(stub), "mt unsafe call");
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    95
  // Creation also verifies the object.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    96
  NativeLoadGot* method_loader = nativeLoadGot_at(stub);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    97
  NativeGotJump* jump          = nativeGotJump_at(method_loader->next_instruction_address());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    98
  method_loader->set_data(0);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    99
  jump->set_jump_destination((address)-1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   100
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   101
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   102
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   103
#ifndef PRODUCT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   104
void CompiledPltStaticCall::verify() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   105
  // Verify call.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   106
  _call->verify();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   107
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   108
#ifdef ASSERT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   109
  CodeBlob *cb = CodeCache::find_blob_unsafe((address) _call);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   110
  assert(cb && cb->is_aot(), "CompiledPltStaticCall can only be used on AOTCompiledMethod");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   111
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   112
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   113
  // Verify stub.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   114
  address stub = find_stub();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   115
  assert(stub != NULL, "no stub found for static call");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   116
  // Creation also verifies the object.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   117
  NativeLoadGot*     method_loader = nativeLoadGot_at(stub);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   118
  NativeGotJump*     jump          = nativeGotJump_at(method_loader->next_instruction_address());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   119
  // Verify state.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   120
  assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   121
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   122
#endif // !PRODUCT