6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "precompiled.hpp"
25
26 #include "jvmci/jvmciRuntime.hpp"
27 #include "oops/method.hpp"
28 #include "aot/aotLoader.hpp"
29 #include "aot/aotCodeHeap.hpp"
30
31 #include <dlfcn.h>
32 #include <stdio.h>
33
34 GrowableArray<AOTCodeHeap*>* AOTLoader::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTCodeHeap*> (2, true);
35
36 // Iterate over all AOT CodeHeaps
37 #define FOR_ALL_AOT_HEAPS(heap) for (GrowableArrayIterator<AOTCodeHeap*> heap = heaps()->begin(); heap != heaps()->end(); ++heap)
38
39 void AOTLoader::load_for_klass(instanceKlassHandle kh, Thread* thread) {
40 FOR_ALL_AOT_HEAPS(heap) {
41 (*heap)->load_klass_data(kh, thread);
42 }
43 }
44
45 uint64_t AOTLoader::get_saved_fingerprint(InstanceKlass* ik) {
46 FOR_ALL_AOT_HEAPS(heap) {
47 AOTKlassData* klass_data = (*heap)->find_klass(ik);
48 if (klass_data != NULL) {
49 return klass_data->_fingerprint;
50 }
51 }
52 return 0;
53 }
54
55 bool AOTLoader::find_klass(InstanceKlass* ik) {
56 FOR_ALL_AOT_HEAPS(heap) {
57 if ((*heap)->find_klass(ik) != NULL) {
58 return true;
59 }
60 }
61 return false;
62 }
63
64 bool AOTLoader::contains(address p) {
65 FOR_ALL_AOT_HEAPS(heap) {
66 if ((*heap)->contains(p)) {
67 return true;
68 }
69 }
70 return false;
71 }
72
73 AOTCompiledMethod* AOTLoader::find_aot(address p) {
74 // NMT can walk the stack before heap array is created
75 if (heaps() != NULL) {
76 FOR_ALL_AOT_HEAPS(heap) {
77 if ((*heap)->contains(p)) {
78 return (*heap)->find_aot(p);
79 }
80 }
81 }
82 return NULL;
83 }
84
85 void AOTLoader::oops_do(OopClosure* f) {
86 FOR_ALL_AOT_HEAPS(heap) {
87 (*heap)->oops_do(f);
88 }
89 }
90
91 void AOTLoader::metadata_do(void f(Metadata*)) {
92 FOR_ALL_AOT_HEAPS(heap) {
93 (*heap)->metadata_do(f);
94 }
95 }
96
97 // Flushing and deoptimization in case of evolution
98 void AOTLoader::flush_evol_dependents_on(instanceKlassHandle dependee) {
99 // make non entrant and mark for deoptimization
100 FOR_ALL_AOT_HEAPS(heap) {
101 (*heap)->flush_evol_dependents_on(dependee);
102 }
103 Deoptimization::deoptimize_dependents();
104 }
105
106 /**
107 * List of core modules for which we search for shared libraries.
108 */
109 static const char* modules[] = {
110 "java.base",
111 "java.logging",
112 "jdk.compiler",
113 "jdk.scripting.nashorn",
114 "jdk.vm.ci",
115 "jdk.vm.compiler"
116 };
117
118 void AOTLoader::initialize() {
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "precompiled.hpp"
25
26 #include "aot/aotCodeHeap.hpp"
27 #include "aot/aotLoader.inline.hpp"
28 #include "jvmci/jvmciRuntime.hpp"
29 #include "oops/method.hpp"
30
31 GrowableArray<AOTCodeHeap*>* AOTLoader::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTCodeHeap*> (2, true);
32
33 // Iterate over all AOT CodeHeaps
34 #define FOR_ALL_AOT_HEAPS(heap) for (GrowableArrayIterator<AOTCodeHeap*> heap = heaps()->begin(); heap != heaps()->end(); ++heap)
35
36 void AOTLoader::load_for_klass(const instanceKlassHandle& kh, Thread* thread) {
37 if (UseAOT) {
38 FOR_ALL_AOT_HEAPS(heap) {
39 (*heap)->load_klass_data(kh, thread);
40 }
41 }
42 }
43
44 uint64_t AOTLoader::get_saved_fingerprint(InstanceKlass* ik) {
45 FOR_ALL_AOT_HEAPS(heap) {
46 AOTKlassData* klass_data = (*heap)->find_klass(ik);
47 if (klass_data != NULL) {
48 return klass_data->_fingerprint;
49 }
50 }
51 return 0;
52 }
53
54 bool AOTLoader::find_klass(InstanceKlass* ik) {
55 FOR_ALL_AOT_HEAPS(heap) {
56 if ((*heap)->find_klass(ik) != NULL) {
57 return true;
58 }
59 }
60 return false;
61 }
62
63 bool AOTLoader::contains(address p) {
64 FOR_ALL_AOT_HEAPS(heap) {
65 if ((*heap)->contains(p)) {
66 return true;
67 }
68 }
69 return false;
70 }
71
72 void AOTLoader::oops_do(OopClosure* f) {
73 if (UseAOT) {
74 FOR_ALL_AOT_HEAPS(heap) {
75 (*heap)->oops_do(f);
76 }
77 }
78 }
79
80 void AOTLoader::metadata_do(void f(Metadata*)) {
81 if (UseAOT) {
82 FOR_ALL_AOT_HEAPS(heap) {
83 (*heap)->metadata_do(f);
84 }
85 }
86 }
87
88 address AOTLoader::exception_begin(JavaThread* thread, CodeBlob* blob, address return_address) {
89 assert(blob->is_aot(), "sanity");
90 AOTCompiledMethod* aotm = (AOTCompiledMethod*)blob;
91 // Set flag if return address is a method handle call site.
92 thread->set_is_method_handle_return(aotm->is_method_handle_return(return_address));
93 return aotm->exception_begin();
94 }
95
96 // Flushing and deoptimization in case of evolution
97 void AOTLoader::flush_evol_dependents_on(const instanceKlassHandle& dependee) {
98 // make non entrant and mark for deoptimization
99 FOR_ALL_AOT_HEAPS(heap) {
100 (*heap)->flush_evol_dependents_on(dependee);
101 }
102 Deoptimization::deoptimize_dependents();
103 }
104
105 /**
106 * List of core modules for which we search for shared libraries.
107 */
108 static const char* modules[] = {
109 "java.base",
110 "java.logging",
111 "jdk.compiler",
112 "jdk.scripting.nashorn",
113 "jdk.vm.ci",
114 "jdk.vm.compiler"
115 };
116
117 void AOTLoader::initialize() {
|