src/hotspot/share/aot/aotCompiledMethod.cpp
author naoto
Tue, 09 Jul 2019 08:05:38 -0700
changeset 55627 9c1885fb2a42
parent 55499 1887e16a5657
child 58226 408c445d04e8
permissions -rw-r--r--
8227127: Era designator not displayed correctly using the COMPAT provider Reviewed-by: rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     1
/*
53147
db1d11c253d8 8216010: Change callers of build_u2_from() to call Bytes::get_Java_u2() instead
hseigel
parents: 52882
diff changeset
     2
 * Copyright (c) 2016, 2019, 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
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    24
#include "precompiled.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    25
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    26
#include "aot/aotCodeHeap.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    27
#include "aot/aotLoader.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    28
#include "aot/compiledIC_aot.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    29
#include "code/codeCache.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    30
#include "code/compiledIC.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    31
#include "code/nativeInst.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    32
#include "compiler/compilerOracle.hpp"
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49361
diff changeset
    33
#include "gc/shared/cardTableBarrierSet.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    34
#include "gc/shared/collectedHeap.hpp"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 48557
diff changeset
    35
#include "oops/method.inline.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49455
diff changeset
    36
#include "runtime/frame.inline.hpp"
49361
1956d0ec092a 8199319: Remove handles.inline.hpp include from reflectionUtils.hpp
stefank
parents: 49340
diff changeset
    37
#include "runtime/handles.inline.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    38
#include "runtime/java.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    39
#include "runtime/os.hpp"
49594
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents: 49480
diff changeset
    40
#include "runtime/safepointVerifiers.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    41
#include "runtime/sharedRuntime.hpp"
53147
db1d11c253d8 8216010: Change callers of build_u2_from() to call Bytes::get_Java_u2() instead
hseigel
parents: 52882
diff changeset
    42
#include "utilities/sizes.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    43
#include "utilities/xmlstream.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    44
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    45
#include <stdio.h>
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    46
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    47
#if 0
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    48
static void metadata_oops_do(Metadata** metadata_begin, Metadata **metadata_end, OopClosure* f) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    49
  // Visit the metadata/oops section
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    50
  for (Metadata** p = metadata_begin; p < metadata_end; p++) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    51
    Metadata* m = *p;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    52
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    53
    intptr_t meta = (intptr_t)m;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    54
    if ((meta & 1) == 1) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    55
      // already resolved
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    56
      m = (Metadata*)(meta & ~1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    57
    } else {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    58
      continue;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    59
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    60
    assert(Metaspace::contains(m), "");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    61
    if (m->is_method()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    62
      m = ((Method*)m)->method_holder();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    63
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    64
    assert(m->is_klass(), "must be");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    65
    oop o = ((Klass*)m)->klass_holder();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    66
    if (o != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    67
      f->do_oop(&o);
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
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    71
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    72
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49455
diff changeset
    73
address* AOTCompiledMethod::orig_pc_addr(const frame* fr) {
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49455
diff changeset
    74
  return (address*) ((address)fr->unextended_sp() + _meta->orig_pc_offset());
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49455
diff changeset
    75
}
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49455
diff changeset
    76
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    77
oop AOTCompiledMethod::oop_at(int index) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    78
  if (index == 0) { // 0 is reserved
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    79
    return NULL;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    80
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    81
  Metadata** entry = _metadata_got + (index - 1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    82
  intptr_t meta = (intptr_t)*entry;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    83
  if ((meta & 1) == 1) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    84
    // already resolved
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    85
    Klass* k = (Klass*)(meta & ~1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    86
    return k->java_mirror();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    87
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    88
  // The entry is string which we need to resolve.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    89
  const char* meta_name = _heap->get_name_at((int)meta);
53147
db1d11c253d8 8216010: Change callers of build_u2_from() to call Bytes::get_Java_u2() instead
hseigel
parents: 52882
diff changeset
    90
  int klass_len = Bytes::get_Java_u2((address)meta_name);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    91
  const char* klass_name = meta_name + 2;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    92
  // Quick check the current method's holder.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    93
  Klass* k = _method->method_holder();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    94
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    95
  ResourceMark rm; // for signature_name()
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    96
  if (strncmp(k->signature_name(), klass_name, klass_len) != 0) { // Does not match?
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    97
    // Search klass in got cells in DSO which have this compiled method.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    98
    k = _heap->get_klass_from_got(klass_name, klass_len, _method);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    99
  }
53147
db1d11c253d8 8216010: Change callers of build_u2_from() to call Bytes::get_Java_u2() instead
hseigel
parents: 52882
diff changeset
   100
  int method_name_len = Bytes::get_Java_u2((address)klass_name + klass_len);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   101
  guarantee(method_name_len == 0, "only klass is expected here");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   102
  meta = ((intptr_t)k) | 1;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   103
  *entry = (Metadata*)meta; // Should be atomic on x64
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   104
  return k->java_mirror();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   105
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   106
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   107
Metadata* AOTCompiledMethod::metadata_at(int index) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   108
  if (index == 0) { // 0 is reserved
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   109
    return NULL;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   110
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   111
  assert(index - 1 < _metadata_size, "");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   112
  {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   113
    Metadata** entry = _metadata_got + (index - 1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   114
    intptr_t meta = (intptr_t)*entry;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   115
    if ((meta & 1) == 1) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   116
      // already resolved
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   117
      Metadata *m = (Metadata*)(meta & ~1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   118
      return m;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   119
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   120
    // The entry is string which we need to resolve.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   121
    const char* meta_name = _heap->get_name_at((int)meta);
53147
db1d11c253d8 8216010: Change callers of build_u2_from() to call Bytes::get_Java_u2() instead
hseigel
parents: 52882
diff changeset
   122
    int klass_len = Bytes::get_Java_u2((address)meta_name);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   123
    const char* klass_name = meta_name + 2;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   124
    // Quick check the current method's holder.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   125
    Klass* k = _method->method_holder();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   126
    bool klass_matched = true;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   127
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   128
    ResourceMark rm; // for signature_name() and find_method()
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   129
    if (strncmp(k->signature_name(), klass_name, klass_len) != 0) { // Does not match?
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   130
      // Search klass in got cells in DSO which have this compiled method.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   131
      k = _heap->get_klass_from_got(klass_name, klass_len, _method);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   132
      klass_matched = false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   133
    }
53147
db1d11c253d8 8216010: Change callers of build_u2_from() to call Bytes::get_Java_u2() instead
hseigel
parents: 52882
diff changeset
   134
    int method_name_len = Bytes::get_Java_u2((address)klass_name + klass_len);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   135
    if (method_name_len == 0) { // Array or Klass name only?
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   136
      meta = ((intptr_t)k) | 1;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   137
      *entry = (Metadata*)meta; // Should be atomic on x64
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   138
      return (Metadata*)k;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   139
    } else { // Method
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   140
      // Quick check the current method's name.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   141
      Method* m = _method;
53147
db1d11c253d8 8216010: Change callers of build_u2_from() to call Bytes::get_Java_u2() instead
hseigel
parents: 52882
diff changeset
   142
      int signature_len = Bytes::get_Java_u2((address)klass_name + klass_len + 2 + method_name_len);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   143
      int full_len = 2 + klass_len + 2 + method_name_len + 2 + signature_len;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   144
      if (!klass_matched || memcmp(_name, meta_name, full_len) != 0) { // Does not match?
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   145
        Thread* thread = Thread::current();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   146
        const char* method_name = klass_name + klass_len;
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   147
        m = AOTCodeHeap::find_method(k, thread, method_name);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   148
      }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   149
      meta = ((intptr_t)m) | 1;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   150
      *entry = (Metadata*)meta; // Should be atomic on x64
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   151
      return (Metadata*)m;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   152
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   153
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   154
  ShouldNotReachHere(); return NULL;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   155
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   156
52882
8b8935b5cfd4 8214401: [AOT] crash in ClassLoaderData::is_alive() with AOTed jdk.base
eosterlund
parents: 52385
diff changeset
   157
void AOTCompiledMethod::do_unloading(bool unloading_occurred) {
8b8935b5cfd4 8214401: [AOT] crash in ClassLoaderData::is_alive() with AOTed jdk.base
eosterlund
parents: 52385
diff changeset
   158
  unload_nmethod_caches(unloading_occurred);
8b8935b5cfd4 8214401: [AOT] crash in ClassLoaderData::is_alive() with AOTed jdk.base
eosterlund
parents: 52385
diff changeset
   159
}
8b8935b5cfd4 8214401: [AOT] crash in ClassLoaderData::is_alive() with AOTed jdk.base
eosterlund
parents: 52385
diff changeset
   160
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   161
bool AOTCompiledMethod::make_not_entrant_helper(int new_state) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   162
  // Make sure the method is not flushed in case of a safepoint in code below.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   163
  methodHandle the_method(method());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   164
  NoSafepointVerifier nsv;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   165
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   166
  {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   167
    // Enter critical section.  Does not block for safepoint.
55499
1887e16a5657 8226699: [BACKOUT] JDK-8221734 Deoptimize with handshakes
dcubed
parents: 55005
diff changeset
   168
    MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   169
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   170
    if (*_state_adr == new_state) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   171
      // another thread already performed this transition so nothing
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   172
      // to do, but return false to indicate this.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   173
      return false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   174
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   175
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   176
    // Change state
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   177
    OrderAccess::storestore();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   178
    *_state_adr = new_state;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   179
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   180
    // Log the transition once
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   181
    log_state_change();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   182
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   183
#ifdef TIERED
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   184
    // Remain non-entrant forever
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   185
    if (new_state == not_entrant && method() != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   186
        method()->set_aot_code(NULL);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   187
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   188
#endif
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   189
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   190
    // Remove AOTCompiledMethod from method.
55499
1887e16a5657 8226699: [BACKOUT] JDK-8221734 Deoptimize with handshakes
dcubed
parents: 55005
diff changeset
   191
    if (method() != NULL && (method()->code() == this ||
1887e16a5657 8226699: [BACKOUT] JDK-8221734 Deoptimize with handshakes
dcubed
parents: 55005
diff changeset
   192
                             method()->from_compiled_entry() == verified_entry_point())) {
1887e16a5657 8226699: [BACKOUT] JDK-8221734 Deoptimize with handshakes
dcubed
parents: 55005
diff changeset
   193
      HandleMark hm;
1887e16a5657 8226699: [BACKOUT] JDK-8221734 Deoptimize with handshakes
dcubed
parents: 55005
diff changeset
   194
      method()->clear_code(false /* already owns Patching_lock */);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   195
    }
55499
1887e16a5657 8226699: [BACKOUT] JDK-8221734 Deoptimize with handshakes
dcubed
parents: 55005
diff changeset
   196
  } // leave critical region under Patching_lock
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   197
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   198
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   199
  if (TraceCreateZombies) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   200
    ResourceMark m;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   201
    const char *new_state_str = (new_state == not_entrant) ? "not entrant" : "not used";
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   202
    tty->print_cr("aot method <" INTPTR_FORMAT "> %s code made %s", p2i(this), this->method() ? this->method()->name_and_sig_as_C_string() : "null", new_state_str);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   203
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   204
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   205
  return true;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   206
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   207
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 50995
diff changeset
   208
#ifdef TIERED
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   209
bool AOTCompiledMethod::make_entrant() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   210
  assert(!method()->is_old(), "reviving evolved method!");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   211
  assert(*_state_adr != not_entrant, "%s", method()->has_aot_code() ? "has_aot_code() not cleared" : "caller didn't check has_aot_code()");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   212
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   213
  // Make sure the method is not flushed in case of a safepoint in code below.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   214
  methodHandle the_method(method());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   215
  NoSafepointVerifier nsv;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   216
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   217
  {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   218
    // Enter critical section.  Does not block for safepoint.
55499
1887e16a5657 8226699: [BACKOUT] JDK-8221734 Deoptimize with handshakes
dcubed
parents: 55005
diff changeset
   219
    MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   220
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   221
    if (*_state_adr == in_use) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   222
      // another thread already performed this transition so nothing
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   223
      // to do, but return false to indicate this.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   224
      return false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   225
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   226
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   227
    // Change state
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   228
    OrderAccess::storestore();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   229
    *_state_adr = in_use;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   230
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   231
    // Log the transition once
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   232
    log_state_change();
55499
1887e16a5657 8226699: [BACKOUT] JDK-8221734 Deoptimize with handshakes
dcubed
parents: 55005
diff changeset
   233
  } // leave critical region under Patching_lock
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   234
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   235
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   236
  if (TraceCreateZombies) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   237
    ResourceMark m;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   238
    tty->print_cr("aot method <" INTPTR_FORMAT "> %s code made entrant", p2i(this), this->method() ? this->method()->name_and_sig_as_C_string() : "null");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   239
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   240
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   241
  return true;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   242
}
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 50995
diff changeset
   243
#endif // TIERED
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   244
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   245
// Iterate over metadata calling this function.   Used by RedefineClasses
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   246
// Copied from nmethod::metadata_do
54150
5529640c5f67 8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents: 53641
diff changeset
   247
void AOTCompiledMethod::metadata_do(MetadataClosure* f) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   248
  address low_boundary = verified_entry_point();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   249
  {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   250
    // Visit all immediate references that are embedded in the instruction stream.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   251
    RelocIterator iter(this, low_boundary);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   252
    while (iter.next()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   253
      if (iter.type() == relocInfo::metadata_type ) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   254
        metadata_Relocation* r = iter.metadata_reloc();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   255
        // In this metadata, we must only follow those metadatas directly embedded in
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   256
        // the code.  Other metadatas (oop_index>0) are seen as part of
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   257
        // the metadata section below.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   258
        assert(1 == (r->metadata_is_immediate()) +
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   259
               (r->metadata_addr() >= metadata_begin() && r->metadata_addr() < metadata_end()),
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   260
               "metadata must be found in exactly one place");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   261
        if (r->metadata_is_immediate() && r->metadata_value() != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   262
          Metadata* md = r->metadata_value();
54150
5529640c5f67 8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents: 53641
diff changeset
   263
          if (md != _method) f->do_metadata(md);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   264
        }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   265
      } else if (iter.type() == relocInfo::virtual_call_type) {
50995
3c59afe1afc9 8206394: missing ResourceMark in AOTCompiledMethod::metadata_do, AOTCompiledMethod::clear_inline_caches , CompiledMethod::clear_ic_stubs , CompiledMethod::cleanup_inline_caches_impl
mbaesken
parents: 50416
diff changeset
   266
        ResourceMark rm;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   267
        // Check compiledIC holders associated with this nmethod
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   268
        CompiledIC *ic = CompiledIC_at(&iter);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   269
        if (ic->is_icholder_call()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   270
          CompiledICHolder* cichk = ic->cached_icholder();
54150
5529640c5f67 8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents: 53641
diff changeset
   271
          f->do_metadata(cichk->holder_metadata());
5529640c5f67 8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents: 53641
diff changeset
   272
          f->do_metadata(cichk->holder_klass());
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   273
        } else {
43942
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   274
          // Get Klass* or NULL (if value is -1) from GOT cell of virtual call PLT stub.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   275
          Metadata* ic_oop = ic->cached_metadata();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   276
          if (ic_oop != NULL) {
54150
5529640c5f67 8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents: 53641
diff changeset
   277
            f->do_metadata(ic_oop);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   278
          }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   279
        }
43942
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   280
      } else if (iter.type() == relocInfo::static_call_type ||
54839
e9db10a375d9 8222841: Incorrect static call stub interactions with class unloading
eosterlund
parents: 54669
diff changeset
   281
                 iter.type() == relocInfo::opt_virtual_call_type) {
43942
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   282
        // Check Method* in AOT c2i stub for other calls.
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   283
        Metadata* meta = (Metadata*)nativeLoadGot_at(nativePltCall_at(iter.addr())->plt_c2i_stub())->data();
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   284
        if (meta != NULL) {
54150
5529640c5f67 8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents: 53641
diff changeset
   285
          f->do_metadata(meta);
43942
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   286
        }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   287
      }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   288
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   289
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   290
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   291
  // Visit the metadata section
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   292
  for (Metadata** p = metadata_begin(); p < metadata_end(); p++) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   293
    Metadata* m = *p;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   294
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   295
    intptr_t meta = (intptr_t)m;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   296
    if ((meta & 1) == 1) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   297
      // already resolved
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   298
      m = (Metadata*)(meta & ~1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   299
    } else {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   300
      continue;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   301
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   302
    assert(Metaspace::contains(m), "");
54150
5529640c5f67 8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents: 53641
diff changeset
   303
    f->do_metadata(m);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   304
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   305
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   306
  // Visit metadata not embedded in the other places.
54150
5529640c5f67 8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents: 53641
diff changeset
   307
  if (_method != NULL) f->do_metadata(_method);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   308
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   309
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   310
void AOTCompiledMethod::print() const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   311
  print_on(tty, "AOTCompiledMethod");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   312
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   313
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   314
void AOTCompiledMethod::print_on(outputStream* st) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   315
  print_on(st, "AOTCompiledMethod");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   316
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   317
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   318
// Print out more verbose output usually for a newly created aot method.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   319
void AOTCompiledMethod::print_on(outputStream* st, const char* msg) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   320
  if (st != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   321
    ttyLocker ttyl;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   322
    st->print("%7d ", (int) st->time_stamp().milliseconds());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   323
    st->print("%4d ", _aot_id);    // print compilation number
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   324
    st->print("    aot[%2d]", _heap->dso_id());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   325
    // Stubs have _method == NULL
43942
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   326
    if (_method == NULL) {
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   327
      st->print("   %s", _name);
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   328
    } else {
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   329
      ResourceMark m;
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   330
      st->print("   %s", _method->name_and_sig_as_C_string());
fff6b7b5611f 8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents: 43461
diff changeset
   331
    }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   332
    if (Verbose) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   333
      st->print(" entry at " INTPTR_FORMAT, p2i(_code));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   334
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   335
    if (msg != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   336
      st->print("   %s", msg);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   337
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   338
    st->cr();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   339
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   340
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   341
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   342
void AOTCompiledMethod::print_value_on(outputStream* st) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   343
  st->print("AOTCompiledMethod ");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   344
  print_on(st, NULL);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   345
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   346
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   347
// Print a short set of xml attributes to identify this aot method.  The
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   348
// output should be embedded in some other element.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   349
void AOTCompiledMethod::log_identity(xmlStream* log) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   350
  log->print(" aot_id='%d'", _aot_id);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   351
  log->print(" aot='%2d'", _heap->dso_id());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   352
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   353
52385
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents: 51731
diff changeset
   354
void AOTCompiledMethod::log_state_change() const {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   355
  if (LogCompilation) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   356
    ResourceMark m;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   357
    if (xtty != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   358
      ttyLocker ttyl;  // keep the following output all in one block
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   359
      if (*_state_adr == not_entrant) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   360
        xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   361
                         os::current_thread_id());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   362
      } else if (*_state_adr == not_used) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   363
        xtty->begin_elem("make_not_used thread='" UINTX_FORMAT "'",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   364
                         os::current_thread_id());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   365
      } else if (*_state_adr == in_use) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   366
        xtty->begin_elem("make_entrant thread='" UINTX_FORMAT "'",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   367
                         os::current_thread_id());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   368
      }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   369
      log_identity(xtty);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   370
      xtty->stamp();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   371
      xtty->end_elem();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   372
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   373
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   374
  if (PrintCompilation) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   375
    ResourceMark m;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   376
    if (*_state_adr == not_entrant) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   377
      print_on(tty, "made not entrant");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   378
    } else if (*_state_adr == not_used) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   379
      print_on(tty, "made not used");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   380
    } else if (*_state_adr == in_use) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   381
      print_on(tty, "made entrant");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   382
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   383
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   384
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   385
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   386
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   387
NativeInstruction* PltNativeCallWrapper::get_load_instruction(virtual_call_Relocation* r) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   388
  return nativeLoadGot_at(_call->plt_load_got());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   389
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   390
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   391
void PltNativeCallWrapper::verify_resolve_call(address dest) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   392
  CodeBlob* db = CodeCache::find_blob_unsafe(dest);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   393
  if (db == NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   394
    assert(dest == _call->plt_resolve_call(), "sanity");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   395
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   396
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   397
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   398
void PltNativeCallWrapper::set_to_interpreted(const methodHandle& method, CompiledICInfo& info) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   399
  assert(!info.to_aot(), "only for nmethod");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   400
  CompiledPltStaticCall* csc = CompiledPltStaticCall::at(instruction_address());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   401
  csc->set_to_interpreted(method, info.entry());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   402
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   403
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   404
NativeCallWrapper* AOTCompiledMethod::call_wrapper_at(address call) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   405
  return new PltNativeCallWrapper((NativePltCall*) call);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   406
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   407
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   408
NativeCallWrapper* AOTCompiledMethod::call_wrapper_before(address return_pc) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   409
  return new PltNativeCallWrapper(nativePltCall_before(return_pc));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   410
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   411
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   412
CompiledStaticCall* AOTCompiledMethod::compiledStaticCall_at(Relocation* call_site) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   413
  return CompiledPltStaticCall::at(call_site);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   414
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   415
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   416
CompiledStaticCall* AOTCompiledMethod::compiledStaticCall_at(address call_site) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   417
  return CompiledPltStaticCall::at(call_site);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   418
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   419
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   420
CompiledStaticCall* AOTCompiledMethod::compiledStaticCall_before(address return_addr) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   421
  return CompiledPltStaticCall::before(return_addr);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   422
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   423
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   424
address AOTCompiledMethod::call_instruction_address(address pc) const {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   425
  NativePltCall* pltcall = nativePltCall_before(pc);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   426
  return pltcall->instruction_address();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   427
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   428
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   429
void AOTCompiledMethod::clear_inline_caches() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   430
  assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   431
  if (is_zombie()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   432
    return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   433
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   434
50995
3c59afe1afc9 8206394: missing ResourceMark in AOTCompiledMethod::metadata_do, AOTCompiledMethod::clear_inline_caches , CompiledMethod::clear_ic_stubs , CompiledMethod::cleanup_inline_caches_impl
mbaesken
parents: 50416
diff changeset
   435
  ResourceMark rm;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   436
  RelocIterator iter(this);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   437
  while (iter.next()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   438
    iter.reloc()->clear_inline_cache();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   439
    if (iter.type() == relocInfo::opt_virtual_call_type) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   440
      CompiledIC* cic = CompiledIC_at(&iter);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   441
      assert(cic->is_clean(), "!");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   442
      nativePltCall_at(iter.addr())->set_stub_to_clean();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   443
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   444
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   445
}