src/hotspot/share/aot/aotLoader.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58282 03fce7b04b42
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     1
/*
53582
881c5fbeb849 8218041: Assorted wrong/missing includes
rehn
parents: 52333
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
#include "aot/aotCodeHeap.hpp"
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    26
#include "aot/aotLoader.inline.hpp"
55160
a8ee59471f55 8225202: Add missing include after JDK-8223320
iveresov
parents: 55159
diff changeset
    27
#include "classfile/javaClasses.hpp"
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
    28
#include "jvm.h"
49360
886acec3b4c6 8199275: Fix inclusions of allocation.inline.hpp
stefank
parents: 48152
diff changeset
    29
#include "memory/allocation.inline.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    30
#include "memory/resourceArea.hpp"
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
    31
#include "oops/compressedOops.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    32
#include "oops/method.hpp"
49361
1956d0ec092a 8199319: Remove handles.inline.hpp include from reflectionUtils.hpp
stefank
parents: 49360
diff changeset
    33
#include "runtime/handles.inline.hpp"
53582
881c5fbeb849 8218041: Assorted wrong/missing includes
rehn
parents: 52333
diff changeset
    34
#include "runtime/os.inline.hpp"
46629
8eeacdc76bf2 8183262: noexecstack check in os::dll_load on Linux is too expensive
kvn
parents: 46560
diff changeset
    35
#include "runtime/timerTrace.hpp"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    36
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    37
GrowableArray<AOTCodeHeap*>* AOTLoader::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTCodeHeap*> (2, true);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    38
GrowableArray<AOTLib*>* AOTLoader::_libraries = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTLib*> (2, true);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    39
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    40
// Iterate over all AOT CodeHeaps
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    41
#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
    42
// Iterate over all AOT Libraries
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    43
#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
    44
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
    45
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
    46
  if (ik->is_unsafe_anonymous()) {
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    47
    // don't even bother
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    48
    return;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    49
  }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    50
  if (UseAOT) {
52333
c401c536cea1 8211743: [AOT] crash in ScopeDesc::decode_body() when JVMTI walks AOT frames
dlong
parents: 52145
diff changeset
    51
    // We allow hotswap to be enabled after the onload phase, but not breakpoints
c401c536cea1 8211743: [AOT] crash in ScopeDesc::decode_body() when JVMTI walks AOT frames
dlong
parents: 52145
diff changeset
    52
    assert(!JvmtiExport::can_post_breakpoint(), "AOT should have been disabled.");
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    53
    FOR_ALL_AOT_HEAPS(heap) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
    54
      (*heap)->load_klass_data(ik, thread);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    55
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    56
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    57
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    58
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    59
uint64_t AOTLoader::get_saved_fingerprint(InstanceKlass* ik) {
51770
b19734760ed3 8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents: 51731
diff changeset
    60
  assert(UseAOT, "called only when AOT is enabled");
51444
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 49847
diff changeset
    61
  if (ik->is_unsafe_anonymous()) {
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    62
    // don't even bother
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    63
    return 0;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    64
  }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    65
  FOR_ALL_AOT_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    66
    AOTKlassData* klass_data = (*heap)->find_klass(ik);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    67
    if (klass_data != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    68
      return klass_data->_fingerprint;
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
  return 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    72
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    73
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    74
void AOTLoader::oops_do(OopClosure* f) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    75
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    76
    FOR_ALL_AOT_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    77
      (*heap)->oops_do(f);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    78
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    79
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    80
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    81
54150
5529640c5f67 8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents: 53641
diff changeset
    82
void AOTLoader::metadata_do(MetadataClosure* f) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    83
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    84
    FOR_ALL_AOT_HEAPS(heap) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    85
      (*heap)->metadata_do(f);
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
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    89
53641
c572eb605087 8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents: 53582
diff changeset
    90
void AOTLoader::mark_evol_dependent_methods(InstanceKlass* dependee) {
c572eb605087 8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents: 53582
diff changeset
    91
  if (UseAOT) {
c572eb605087 8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents: 53582
diff changeset
    92
    FOR_ALL_AOT_HEAPS(heap) {
c572eb605087 8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents: 53582
diff changeset
    93
      (*heap)->mark_evol_dependent_methods(dependee);
c572eb605087 8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents: 53582
diff changeset
    94
    }
c572eb605087 8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents: 53582
diff changeset
    95
  }
c572eb605087 8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents: 53582
diff changeset
    96
}
c572eb605087 8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents: 53582
diff changeset
    97
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    98
/**
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    99
 * List of core modules for which we search for shared libraries.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   100
 */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   101
static const char* modules[] = {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   102
  "java.base",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   103
  "java.logging",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   104
  "jdk.compiler",
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   105
  "jdk.scripting.nashorn",
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 42658
diff changeset
   106
  "jdk.internal.vm.ci",
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 42658
diff changeset
   107
  "jdk.internal.vm.compiler"
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   108
};
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   109
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   110
void AOTLoader::initialize() {
46629
8eeacdc76bf2 8183262: noexecstack check in os::dll_load on Linux is too expensive
kvn
parents: 46560
diff changeset
   111
  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
   112
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   113
  if (FLAG_IS_DEFAULT(UseAOT) && AOTLibrary != NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   114
    // Don't need to set UseAOT on command line when AOTLibrary is specified
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   115
    FLAG_SET_DEFAULT(UseAOT, true);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   116
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   117
  if (UseAOT) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   118
    // EagerInitialization is not compatible with AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   119
    if (EagerInitialization) {
42658
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   120
      if (PrintAOT) {
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   121
        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
   122
      }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   123
      FLAG_SET_DEFAULT(UseAOT, false);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   124
      return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   125
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   126
52333
c401c536cea1 8211743: [AOT] crash in ScopeDesc::decode_body() when JVMTI walks AOT frames
dlong
parents: 52145
diff changeset
   127
    if (JvmtiExport::can_post_breakpoint()) {
51770
b19734760ed3 8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents: 51731
diff changeset
   128
      if (PrintAOT) {
52333
c401c536cea1 8211743: [AOT] crash in ScopeDesc::decode_body() when JVMTI walks AOT frames
dlong
parents: 52145
diff changeset
   129
        warning("JVMTI capability to post breakpoint is not compatible with AOT (switching AOT off)");
51770
b19734760ed3 8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents: 51731
diff changeset
   130
      }
b19734760ed3 8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents: 51731
diff changeset
   131
      FLAG_SET_DEFAULT(UseAOT, false);
b19734760ed3 8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents: 51731
diff changeset
   132
      return;
b19734760ed3 8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents: 51731
diff changeset
   133
    }
b19734760ed3 8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents: 51731
diff changeset
   134
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   135
    // -Xint is not compatible with AOT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   136
    if (Arguments::is_interpreter_only()) {
42658
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   137
      if (PrintAOT) {
9b8b24e4fc01 8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents: 42650
diff changeset
   138
        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
   139
      }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   140
      FLAG_SET_DEFAULT(UseAOT, false);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   141
      return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   142
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   143
52145
89f3b013ab8f 8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents: 51770
diff changeset
   144
#ifdef _WINDOWS
89f3b013ab8f 8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents: 51770
diff changeset
   145
    const char pathSep = ';';
89f3b013ab8f 8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents: 51770
diff changeset
   146
#else
89f3b013ab8f 8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents: 51770
diff changeset
   147
    const char pathSep = ':';
89f3b013ab8f 8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents: 51770
diff changeset
   148
#endif
89f3b013ab8f 8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents: 51770
diff changeset
   149
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   150
    // Scan the AOTLibrary option.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   151
    if (AOTLibrary != NULL) {
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   152
      const int len = (int)strlen(AOTLibrary);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   153
      char* cp  = NEW_C_HEAP_ARRAY(char, len+1, mtCode);
58282
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 55160
diff changeset
   154
      memcpy(cp, AOTLibrary, len);
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 55160
diff changeset
   155
      cp[len] = '\0';
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 55160
diff changeset
   156
      char* end = cp + len;
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 55160
diff changeset
   157
      while (cp < end) {
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 55160
diff changeset
   158
        const char* name = cp;
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 55160
diff changeset
   159
        while ((*cp) != '\0' && (*cp) != '\n' && (*cp) != ',' && (*cp) != pathSep) cp++;
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 55160
diff changeset
   160
        cp[0] = '\0';  // Terminate name
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 55160
diff changeset
   161
        cp++;
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 55160
diff changeset
   162
        load_library(name, true);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   163
      }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   164
    }
48152
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   165
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   166
    // 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
   167
    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
   168
    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
   169
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   170
    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
   171
      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
   172
      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
   173
      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
   174
    }
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   175
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   176
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   177
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   178
void AOTLoader::universe_init() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   179
  if (UseAOT && libraries_count() > 0) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   180
    // Shifts are static values which initialized by 0 until java heap initialization.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   181
    // AOT libs are loaded before heap initialized so shift values are not set.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   182
    // 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
   183
    // 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
   184
    // Check shifts value to make sure thay did not change.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   185
    if (UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) {
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
   186
      int oop_shift = CompressedOops::shift();
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   187
      FOR_ALL_AOT_LIBRARIES(lib) {
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
   188
        (*lib)->verify_flag((*lib)->config()->_narrowOopShift, oop_shift, "CompressedOops::shift");
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   189
      }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   190
      if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
   191
        int klass_shift = CompressedKlassPointers::shift();
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   192
        FOR_ALL_AOT_LIBRARIES(lib) {
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
   193
          (*lib)->verify_flag((*lib)->config()->_narrowKlassShift, klass_shift, "CompressedKlassPointers::shift");
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   194
        }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   195
      }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   196
    }
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   197
    // Create heaps for all valid libraries
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   198
    FOR_ALL_AOT_LIBRARIES(lib) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   199
      if ((*lib)->is_valid()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   200
        AOTCodeHeap* heap = new AOTCodeHeap(*lib);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   201
        {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54150
diff changeset
   202
          MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   203
          add_heap(heap);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   204
          CodeCache::add_heap(heap);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   205
        }
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   206
      } else {
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   207
        // Unload invalid libraries
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   208
        os::dll_unload((*lib)->dl_handle());
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   209
      }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   210
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   211
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   212
  if (heaps_count() == 0) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   213
    if (FLAG_IS_DEFAULT(UseAOT)) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   214
      FLAG_SET_DEFAULT(UseAOT, false);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   215
    }
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
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   219
// 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
   220
// 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
   221
// 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
   222
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   223
void AOTLoader::set_narrow_oop_shift() {
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   224
  // 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
   225
  if (UseAOT && libraries_count() > 0 &&
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   226
      UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) {
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
   227
    if (CompressedOops::shift() == 0) {
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   228
      // 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
   229
      // at this point when nobody used it yet.
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
   230
      CompressedOops::set_shift(AOTLib::narrow_oop_shift());
49847
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   231
    }
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   232
  }
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   233
}
f22c0b4caad7 8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents: 49361
diff changeset
   234
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   235
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
   236
  // This method is called from Metaspace::set_narrow_klass_base_and_shift().
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   237
  if (UseAOT && libraries_count() > 0 &&
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   238
      UseCompressedOops && AOTLib::narrow_oop_shift_initialized() &&
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   239
      UseCompressedClassPointers) {
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
   240
    if (CompressedKlassPointers::shift() == 0) {
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 54669
diff changeset
   241
      CompressedKlassPointers::set_shift(AOTLib::narrow_klass_shift());
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   242
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   243
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   244
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   245
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   246
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
   247
  // 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
   248
  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
   249
  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
   250
  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
   251
  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
   252
    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
   253
    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
   254
    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
   255
    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
   256
      if (PrintAOT) {
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   257
        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
   258
      }
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   259
      return;
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   260
    }
bef902d8fef1 8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents: 47765
diff changeset
   261
  }
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   262
  char ebuf[1024];
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   263
  void* handle = os::dll_load(name, ebuf, sizeof ebuf);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   264
  if (handle == NULL) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   265
    if (exit_on_error) {
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   266
      tty->print_cr("error opening file: %s", ebuf);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   267
      vm_exit(1);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   268
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   269
    return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   270
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   271
  const int dso_id = libraries_count() + 1;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   272
  AOTLib* lib = new AOTLib(handle, name, dso_id);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   273
  if (!lib->is_valid()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   274
    delete lib;
46260
5de61384fba6 8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents: 42658
diff changeset
   275
    os::dll_unload(handle);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   276
    return;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   277
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   278
  add_library(lib);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   279
}
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   280
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   281
#ifndef PRODUCT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   282
void AOTLoader::print_statistics() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   283
  { ttyLocker ttyl;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   284
    tty->print_cr("--- AOT Statistics ---");
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   285
    tty->print_cr("AOT libraries loaded: %d", heaps_count());
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   286
    AOTCodeHeap::print_statistics();
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
#endif
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   290
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   291
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   292
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
   293
  if (!UseAOT) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   294
    return true;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   295
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   296
  JavaThread* thread = JavaThread::current();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   297
  ResourceMark rm(thread);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   298
  RegisterMap map(thread, false);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   299
  frame caller_frame = thread->last_frame().sender(&map); // Skip stub
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   300
  CodeBlob* caller_cb = caller_frame.cb();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   301
  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
   302
  CompiledMethod* cm = caller_cb->as_compiled_method();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   303
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   304
  if (!cm->is_aot()) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   305
    return true;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   306
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   307
  AOTCompiledMethod* aot = (AOTCompiledMethod*)cm;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   308
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   309
  AOTCodeHeap* caller_heap = NULL;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   310
  FOR_ALL_AOT_HEAPS(heap) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   311
    if ((*heap)->contains_blob(aot)) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   312
      caller_heap = *heap;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   313
      break;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   314
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   315
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   316
  guarantee(caller_heap != NULL, "CodeHeap not found");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   317
  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
   318
  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
   319
  return success;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   320
}
55159
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   321
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   322
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   323
// This should be called very early during startup before any of the AOTed methods that use boxes can deoptimize.
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   324
// Deoptimization machinery expects the caches to be present and populated.
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   325
void AOTLoader::initialize_box_caches(TRAPS) {
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   326
  if (!UseAOT || libraries_count() == 0) {
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   327
    return;
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   328
  }
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   329
  TraceTime timer("AOT initialization of box caches", TRACETIME_LOG(Info, aot, startuptime));
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   330
  Symbol* box_classes[] = { java_lang_Boolean::symbol(), java_lang_Byte_ByteCache::symbol(),
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   331
    java_lang_Short_ShortCache::symbol(), java_lang_Character_CharacterCache::symbol(),
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   332
    java_lang_Integer_IntegerCache::symbol(), java_lang_Long_LongCache::symbol() };
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   333
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   334
  for (unsigned i = 0; i < sizeof(box_classes) / sizeof(Symbol*); i++) {
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   335
    Klass* k = SystemDictionary::resolve_or_fail(box_classes[i], true, CHECK);
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   336
    InstanceKlass* ik = InstanceKlass::cast(k);
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   337
    if (ik->is_not_initialized()) {
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   338
      ik->initialize(CHECK);
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   339
    }
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   340
  }
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54780
diff changeset
   341
}