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