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 #include "prims/jvm.h"
31 #include "runtime/os.hpp"
32 #include "runtime/timerTrace.hpp"
33
34 GrowableArray<AOTCodeHeap*>* AOTLoader::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTCodeHeap*> (2, true);
35 GrowableArray<AOTLib*>* AOTLoader::_libraries = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTLib*> (2, true);
36
37 // Iterate over all AOT CodeHeaps
38 #define FOR_ALL_AOT_HEAPS(heap) for (GrowableArrayIterator<AOTCodeHeap*> heap = heaps()->begin(); heap != heaps()->end(); ++heap)
39 // Iterate over all AOT Libraries
40 #define FOR_ALL_AOT_LIBRARIES(lib) for (GrowableArrayIterator<AOTLib*> lib = libraries()->begin(); lib != libraries()->end(); ++lib)
41
42 void AOTLoader::load_for_klass(InstanceKlass* ik, Thread* thread) {
43 if (UseAOT) {
44 FOR_ALL_AOT_HEAPS(heap) {
45 (*heap)->load_klass_data(ik, thread);
46 }
47 }
48 }
49
50 uint64_t AOTLoader::get_saved_fingerprint(InstanceKlass* ik) {
51 FOR_ALL_AOT_HEAPS(heap) {
52 AOTKlassData* klass_data = (*heap)->find_klass(ik);
53 if (klass_data != NULL) {
54 return klass_data->_fingerprint;
55 }
56 }
57 return 0;
58 }
59
60 bool AOTLoader::find_klass(InstanceKlass* ik) {
61 FOR_ALL_AOT_HEAPS(heap) {
62 if ((*heap)->find_klass(ik) != NULL) {
63 return true;
64 }
65 }
66 return false;
67 }
68
69 bool AOTLoader::contains(address p) {
70 FOR_ALL_AOT_HEAPS(heap) {
242 }
243 const int dso_id = libraries_count() + 1;
244 AOTLib* lib = new AOTLib(handle, name, dso_id);
245 if (!lib->is_valid()) {
246 delete lib;
247 os::dll_unload(handle);
248 return;
249 }
250 add_library(lib);
251 }
252
253 #ifndef PRODUCT
254 void AOTLoader::print_statistics() {
255 { ttyLocker ttyl;
256 tty->print_cr("--- AOT Statistics ---");
257 tty->print_cr("AOT libraries loaded: %d", heaps_count());
258 AOTCodeHeap::print_statistics();
259 }
260 }
261 #endif
|
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 #include "prims/jvm.h"
31 #include "runtime/os.hpp"
32 #include "runtime/timerTrace.hpp"
33
34 GrowableArray<AOTCodeHeap*>* AOTLoader::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTCodeHeap*> (2, true);
35 GrowableArray<AOTLib*>* AOTLoader::_libraries = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTLib*> (2, true);
36
37 // Iterate over all AOT CodeHeaps
38 #define FOR_ALL_AOT_HEAPS(heap) for (GrowableArrayIterator<AOTCodeHeap*> heap = heaps()->begin(); heap != heaps()->end(); ++heap)
39 // Iterate over all AOT Libraries
40 #define FOR_ALL_AOT_LIBRARIES(lib) for (GrowableArrayIterator<AOTLib*> lib = libraries()->begin(); lib != libraries()->end(); ++lib)
41
42 void AOTLoader::load_for_klass(InstanceKlass* ik, Thread* thread) {
43 if (ik->is_anonymous()) {
44 // don't even bother
45 return;
46 }
47 if (UseAOT) {
48 FOR_ALL_AOT_HEAPS(heap) {
49 (*heap)->load_klass_data(ik, thread);
50 }
51 }
52 }
53
54 uint64_t AOTLoader::get_saved_fingerprint(InstanceKlass* ik) {
55 if (ik->is_anonymous()) {
56 // don't even bother
57 return 0;
58 }
59 FOR_ALL_AOT_HEAPS(heap) {
60 AOTKlassData* klass_data = (*heap)->find_klass(ik);
61 if (klass_data != NULL) {
62 return klass_data->_fingerprint;
63 }
64 }
65 return 0;
66 }
67
68 bool AOTLoader::find_klass(InstanceKlass* ik) {
69 FOR_ALL_AOT_HEAPS(heap) {
70 if ((*heap)->find_klass(ik) != NULL) {
71 return true;
72 }
73 }
74 return false;
75 }
76
77 bool AOTLoader::contains(address p) {
78 FOR_ALL_AOT_HEAPS(heap) {
250 }
251 const int dso_id = libraries_count() + 1;
252 AOTLib* lib = new AOTLib(handle, name, dso_id);
253 if (!lib->is_valid()) {
254 delete lib;
255 os::dll_unload(handle);
256 return;
257 }
258 add_library(lib);
259 }
260
261 #ifndef PRODUCT
262 void AOTLoader::print_statistics() {
263 { ttyLocker ttyl;
264 tty->print_cr("--- AOT Statistics ---");
265 tty->print_cr("AOT libraries loaded: %d", heaps_count());
266 AOTCodeHeap::print_statistics();
267 }
268 }
269 #endif
270
271
272 bool AOTLoader::reconcile_dynamic_invoke(InstanceKlass* holder, int index, Method* adapter_method, Klass* appendix_klass) {
273 if (!UseAOT) {
274 return true;
275 }
276 JavaThread* thread = JavaThread::current();
277 ResourceMark rm(thread);
278 RegisterMap map(thread, false);
279 frame caller_frame = thread->last_frame().sender(&map); // Skip stub
280 CodeBlob* caller_cb = caller_frame.cb();
281 guarantee(caller_cb != NULL && caller_cb->is_compiled(), "must be called from compiled method");
282 CompiledMethod* cm = caller_cb->as_compiled_method();
283
284 if (!cm->is_aot()) {
285 return true;
286 }
287 AOTCompiledMethod* aot = (AOTCompiledMethod*)cm;
288
289 AOTCodeHeap* caller_heap = NULL;
290 FOR_ALL_AOT_HEAPS(heap) {
291 if ((*heap)->contains_blob(aot)) {
292 caller_heap = *heap;
293 break;
294 }
295 }
296 guarantee(caller_heap != NULL, "CodeHeap not found");
297 bool success = caller_heap->reconcile_dynamic_invoke(aot, holder, index, adapter_method, appendix_klass);
298 vmassert(success || thread->last_frame().sender(&map).is_deoptimized_frame(), "caller not deoptimized on failure");
299 return success;
300 }
|