src/hotspot/share/aot/aotLoader.cpp
author lfoltan
Mon, 20 Aug 2018 08:25:57 -0400
changeset 51444 3e5d28e6de32
parent 49847 f22c0b4caad7
child 51731 8745f8f1b0f8
permissions -rw-r--r--
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation Summary: Clean up VM anonymous class terminology. Reviewed-by: coleenp, dholmes, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     1
/*
49360
886acec3b4c6 8199275: Fix inclusions of allocation.inline.hpp
stefank
parents: 48152
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
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    24
#include "precompiled.hpp"
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47668
diff changeset
    25
#include "jvm.h"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    26
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    27
#include "aot/aotCodeHeap.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    28
#include "aot/aotLoader.inline.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    29
#include "jvmci/jvmciRuntime.hpp"
49360
886acec3b4c6 8199275: Fix inclusions of allocation.inline.hpp
stefank
parents: 48152
diff changeset
    30
#include "memory/allocation.inline.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    31
#include "oops/method.hpp"
49361
1956d0ec092a 8199319: Remove handles.inline.hpp include from reflectionUtils.hpp
stefank
parents: 49360
diff changeset
    32
#include "runtime/handles.inline.hpp"
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
    33
#include "runtime/os.hpp"
46629
8eeacdc76bf2 8183262: noexecstack check in os::dll_load on Linux is too expensive
kvn
parents: 46560
diff changeset
    34
#include "runtime/timerTrace.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    35
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    36
GrowableArray<AOTCodeHeap*>* AOTLoader::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTCodeHeap*> (2, true);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    37
GrowableArray<AOTLib*>* AOTLoader::_libraries = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTLib*> (2, true);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    38
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    39
// Iterate over all AOT CodeHeaps
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    40
#define FOR_ALL_AOT_HEAPS(heap) for (GrowableArrayIterator<AOTCodeHeap*> heap = heaps()->begin(); heap != heaps()->end(); ++heap)
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    41
// Iterate over all AOT Libraries
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    42
#define FOR_ALL_AOT_LIBRARIES(lib) for (GrowableArrayIterator<AOTLib*> lib = libraries()->begin(); lib != libraries()->end(); ++lib)
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    43
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
    44
void AOTLoader::load_for_klass(InstanceKlass* ik, Thread* thread) {
51444
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 49847
diff changeset
    45
  if (ik->is_unsafe_anonymous()) {
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    46
    // don't even bother
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    47
    return;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    48
  }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    49
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    50
    FOR_ALL_AOT_HEAPS(heap) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
    51
      (*heap)->load_klass_data(ik, thread);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    52
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    53
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    54
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    55
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    56
uint64_t AOTLoader::get_saved_fingerprint(InstanceKlass* ik) {
51444
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 49847
diff changeset
    57
  if (ik->is_unsafe_anonymous()) {
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    58
    // don't even bother
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    59
    return 0;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    60
  }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    61
  FOR_ALL_AOT_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    62
    AOTKlassData* klass_data = (*heap)->find_klass(ik);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    63
    if (klass_data != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    64
      return klass_data->_fingerprint;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    65
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    66
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    67
  return 0;
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
bool AOTLoader::find_klass(InstanceKlass* ik) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    71
  FOR_ALL_AOT_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    72
    if ((*heap)->find_klass(ik) != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    73
      return true;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    74
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    75
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    76
  return false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    77
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    78
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    79
bool AOTLoader::contains(address p) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    80
  FOR_ALL_AOT_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    81
    if ((*heap)->contains(p)) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    82
      return true;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    83
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    84
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    85
  return false;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    86
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    87
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    88
void AOTLoader::oops_do(OopClosure* f) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    89
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    90
    FOR_ALL_AOT_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    91
      (*heap)->oops_do(f);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    92
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    93
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    94
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    95
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    96
void AOTLoader::metadata_do(void f(Metadata*)) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    97
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    98
    FOR_ALL_AOT_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    99
      (*heap)->metadata_do(f);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   100
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   101
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   102
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   103
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   104
// Flushing and deoptimization in case of evolution
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   105
void AOTLoader::flush_evol_dependents_on(InstanceKlass* dependee) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   106
  // make non entrant and mark for deoptimization
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   107
  FOR_ALL_AOT_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   108
    (*heap)->flush_evol_dependents_on(dependee);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   109
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   110
  Deoptimization::deoptimize_dependents();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   111
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   112
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   113
/**
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   114
 * List of core modules for which we search for shared libraries.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   115
 */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   116
static const char* modules[] = {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   117
  "java.base",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   118
  "java.logging",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   119
  "jdk.compiler",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   120
  "jdk.scripting.nashorn",
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 42658
diff changeset
   121
  "jdk.internal.vm.ci",
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 42658
diff changeset
   122
  "jdk.internal.vm.compiler"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   123
};
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   124
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   125
void AOTLoader::initialize() {
46629
8eeacdc76bf2 8183262: noexecstack check in os::dll_load on Linux is too expensive
kvn
parents: 46560
diff changeset
   126
  TraceTime timer("AOT initialization", TRACETIME_LOG(Info, aot, startuptime));
8eeacdc76bf2 8183262: noexecstack check in os::dll_load on Linux is too expensive
kvn
parents: 46560
diff changeset
   127
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   128
  if (FLAG_IS_DEFAULT(UseAOT) && AOTLibrary != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   129
    // Don't need to set UseAOT on command line when AOTLibrary is specified
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   130
    FLAG_SET_DEFAULT(UseAOT, true);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   131
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   132
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   133
    // EagerInitialization is not compatible with AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   134
    if (EagerInitialization) {
42658
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   135
      if (PrintAOT) {
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   136
        warning("EagerInitialization is not compatible with AOT (switching AOT off)");
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   137
      }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   138
      FLAG_SET_DEFAULT(UseAOT, false);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   139
      return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   140
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   141
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   142
    // -Xint is not compatible with AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   143
    if (Arguments::is_interpreter_only()) {
42658
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   144
      if (PrintAOT) {
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   145
        warning("-Xint is not compatible with AOT (switching AOT off)");
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   146
      }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   147
      FLAG_SET_DEFAULT(UseAOT, false);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   148
      return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   149
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   150
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   151
    // Scan the AOTLibrary option.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   152
    if (AOTLibrary != NULL) {
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   153
      const int len = (int)strlen(AOTLibrary);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   154
      char* cp  = NEW_C_HEAP_ARRAY(char, len+1, mtCode);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   155
      if (cp != NULL) { // No memory?
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   156
        memcpy(cp, AOTLibrary, len);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   157
        cp[len] = '\0';
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   158
        char* end = cp + len;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   159
        while (cp < end) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   160
          const char* name = cp;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   161
          while ((*cp) != '\0' && (*cp) != '\n' && (*cp) != ',' && (*cp) != ':' && (*cp) != ';')  cp++;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   162
          cp[0] = '\0';  // Terminate name
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   163
          cp++;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   164
          load_library(name, true);
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
    }
48152
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   168
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   169
    // Load well-know AOT libraries from Java installation directory.
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   170
    const char* home = Arguments::get_java_home();
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   171
    const char* file_separator = os::file_separator();
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   172
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   173
    for (int i = 0; i < (int) (sizeof(modules) / sizeof(const char*)); i++) {
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   174
      char library[JVM_MAXPATHLEN];
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   175
      jio_snprintf(library, sizeof(library), "%s%slib%slib%s%s%s%s", home, file_separator, file_separator, modules[i], UseCompressedOops ? "-coop" : "", UseG1GC ? "" : "-nong1", os::dll_file_extension());
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   176
      load_library(library, false);
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   177
    }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   178
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   179
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   180
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   181
void AOTLoader::universe_init() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   182
  if (UseAOT && libraries_count() > 0) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   183
    // Shifts are static values which initialized by 0 until java heap initialization.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   184
    // AOT libs are loaded before heap initialized so shift values are not set.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   185
    // It is okay since ObjectAlignmentInBytes flag which defines shifts value is set before AOT libs are loaded.
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   186
    // AOT sets shift values during heap and metaspace initialization.
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   187
    // Check shifts value to make sure thay did not change.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   188
    if (UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   189
      int oop_shift = Universe::narrow_oop_shift();
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   190
      FOR_ALL_AOT_LIBRARIES(lib) {
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   191
        (*lib)->verify_flag((*lib)->config()->_narrowOopShift, oop_shift, "Universe::narrow_oop_shift");
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   192
      }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   193
      if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   194
        int klass_shift = Universe::narrow_klass_shift();
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   195
        FOR_ALL_AOT_LIBRARIES(lib) {
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   196
          (*lib)->verify_flag((*lib)->config()->_narrowKlassShift, klass_shift, "Universe::narrow_klass_shift");
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
    }
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   200
    // Create heaps for all valid libraries
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   201
    FOR_ALL_AOT_LIBRARIES(lib) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   202
      if ((*lib)->is_valid()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   203
        AOTCodeHeap* heap = new AOTCodeHeap(*lib);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   204
        {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   205
          MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   206
          add_heap(heap);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   207
          CodeCache::add_heap(heap);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   208
        }
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   209
      } else {
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   210
        // Unload invalid libraries
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   211
        os::dll_unload((*lib)->dl_handle());
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   212
      }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   213
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   214
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   215
  if (heaps_count() == 0) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   216
    if (FLAG_IS_DEFAULT(UseAOT)) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   217
      FLAG_SET_DEFAULT(UseAOT, false);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   218
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   219
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   220
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   221
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   222
// Set shift value for compressed oops and classes based on first AOT library config.
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   223
// AOTLoader::universe_init(), which is called later, will check the shift value again to make sure nobody change it.
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   224
// This code is not executed during CDS dump because it runs in Interpreter mode and AOT is disabled in this mode.
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   225
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   226
void AOTLoader::set_narrow_oop_shift() {
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   227
  // This method is called from Universe::initialize_heap().
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   228
  if (UseAOT && libraries_count() > 0 &&
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   229
      UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) {
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   230
    if (Universe::narrow_oop_shift() == 0) {
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   231
      // 0 is valid shift value for small heap but we can safely increase it
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   232
      // at this point when nobody used it yet.
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   233
      Universe::set_narrow_oop_shift(AOTLib::narrow_oop_shift());
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   234
    }
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   235
  }
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   236
}
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   237
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   238
void AOTLoader::set_narrow_klass_shift() {
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   239
  // This method is called from Metaspace::set_narrow_klass_base_and_shift().
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   240
  if (UseAOT && libraries_count() > 0 &&
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   241
      UseCompressedOops && AOTLib::narrow_oop_shift_initialized() &&
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   242
      UseCompressedClassPointers) {
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   243
    if (Universe::narrow_klass_shift() == 0) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   244
      Universe::set_narrow_klass_shift(AOTLib::narrow_klass_shift());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   245
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   246
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   247
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   248
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   249
void AOTLoader::load_library(const char* name, bool exit_on_error) {
48152
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   250
  // Skip library if a library with the same name is already loaded.
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   251
  const int file_separator = *os::file_separator();
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   252
  const char* start = strrchr(name, file_separator);
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   253
  const char* new_name = (start == NULL) ? name : (start + 1);
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   254
  FOR_ALL_AOT_LIBRARIES(lib) {
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   255
    const char* lib_name = (*lib)->name();
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   256
    start = strrchr(lib_name, file_separator);
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   257
    const char* old_name = (start == NULL) ? lib_name : (start + 1);
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   258
    if (strcmp(old_name, new_name) == 0) {
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   259
      if (PrintAOT) {
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   260
        warning("AOT library %s is already loaded as %s.", name, lib_name);
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   261
      }
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   262
      return;
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   263
    }
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   264
  }
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   265
  char ebuf[1024];
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   266
  void* handle = os::dll_load(name, ebuf, sizeof ebuf);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   267
  if (handle == NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   268
    if (exit_on_error) {
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   269
      tty->print_cr("error opening file: %s", ebuf);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   270
      vm_exit(1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   271
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   272
    return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   273
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   274
  const int dso_id = libraries_count() + 1;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   275
  AOTLib* lib = new AOTLib(handle, name, dso_id);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   276
  if (!lib->is_valid()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   277
    delete lib;
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   278
    os::dll_unload(handle);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   279
    return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   280
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   281
  add_library(lib);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   282
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   283
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   284
#ifndef PRODUCT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   285
void AOTLoader::print_statistics() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   286
  { ttyLocker ttyl;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   287
    tty->print_cr("--- AOT Statistics ---");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   288
    tty->print_cr("AOT libraries loaded: %d", heaps_count());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   289
    AOTCodeHeap::print_statistics();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   290
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   291
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   292
#endif
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   293
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   294
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   295
bool AOTLoader::reconcile_dynamic_invoke(InstanceKlass* holder, int index, Method* adapter_method, Klass* appendix_klass) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   296
  if (!UseAOT) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   297
    return true;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   298
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   299
  JavaThread* thread = JavaThread::current();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   300
  ResourceMark rm(thread);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   301
  RegisterMap map(thread, false);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   302
  frame caller_frame = thread->last_frame().sender(&map); // Skip stub
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   303
  CodeBlob* caller_cb = caller_frame.cb();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   304
  guarantee(caller_cb != NULL && caller_cb->is_compiled(), "must be called from compiled method");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   305
  CompiledMethod* cm = caller_cb->as_compiled_method();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   306
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   307
  if (!cm->is_aot()) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   308
    return true;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   309
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   310
  AOTCompiledMethod* aot = (AOTCompiledMethod*)cm;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   311
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   312
  AOTCodeHeap* caller_heap = NULL;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   313
  FOR_ALL_AOT_HEAPS(heap) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   314
    if ((*heap)->contains_blob(aot)) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   315
      caller_heap = *heap;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   316
      break;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   317
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   318
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   319
  guarantee(caller_heap != NULL, "CodeHeap not found");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   320
  bool success = caller_heap->reconcile_dynamic_invoke(aot, holder, index, adapter_method, appendix_klass);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   321
  vmassert(success || thread->last_frame().sender(&map).is_deoptimized_frame(), "caller not deoptimized on failure");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   322
  return success;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   323
}