< prev index next >

src/hotspot/share/cds/archiveHeapLoader.cpp

Print this page

415 
416 void ArchiveHeapLoader::fill_failed_loaded_heap() {
417   assert(_loading_failed, "must be");
418   if (_loaded_heap_bottom != 0) {
419     assert(_loaded_heap_top != 0, "must be");
420     HeapWord* bottom = (HeapWord*)_loaded_heap_bottom;
421     HeapWord* top = (HeapWord*)_loaded_heap_top;
422     Universe::heap()->fill_with_objects(bottom, top - bottom);
423   }
424 }
425 
426 class PatchNativePointers: public BitMapClosure {
427   Metadata** _start;
428 
429  public:
430   PatchNativePointers(Metadata** start) : _start(start) {}
431 
432   bool do_bit(size_t offset) {
433     Metadata** p = _start + offset;
434     *p = (Metadata*)(address(*p) + MetaspaceShared::relocation_delta());
435     // Currently we have only Klass pointers in heap objects.
436     // This needs to be relaxed when we support other types of native
437     // pointers such as Method.
438     assert(((Klass*)(*p))->is_klass(), "must be");
439     return true;
440   }
441 };
442 
443 void ArchiveHeapLoader::patch_native_pointers() {
444   if (MetaspaceShared::relocation_delta() == 0) {
445     return;
446   }
447 
448   FileMapRegion* r = FileMapInfo::current_info()->region_at(MetaspaceShared::hp);
449   if (r->mapped_base() != nullptr && r->has_ptrmap()) {
450     log_info(cds, heap)("Patching native pointers in heap region");
451     BitMapView bm = r->ptrmap_view();
452     PatchNativePointers patcher((Metadata**)r->mapped_base());
453     bm.iterate(&patcher);
454   }
455 }
456 #endif // INCLUDE_CDS_JAVA_HEAP

415 
416 void ArchiveHeapLoader::fill_failed_loaded_heap() {
417   assert(_loading_failed, "must be");
418   if (_loaded_heap_bottom != 0) {
419     assert(_loaded_heap_top != 0, "must be");
420     HeapWord* bottom = (HeapWord*)_loaded_heap_bottom;
421     HeapWord* top = (HeapWord*)_loaded_heap_top;
422     Universe::heap()->fill_with_objects(bottom, top - bottom);
423   }
424 }
425 
426 class PatchNativePointers: public BitMapClosure {
427   Metadata** _start;
428 
429  public:
430   PatchNativePointers(Metadata** start) : _start(start) {}
431 
432   bool do_bit(size_t offset) {
433     Metadata** p = _start + offset;
434     *p = (Metadata*)(address(*p) + MetaspaceShared::relocation_delta());




435     return true;
436   }
437 };
438 
439 void ArchiveHeapLoader::patch_native_pointers() {
440   if (MetaspaceShared::relocation_delta() == 0) {
441     return;
442   }
443 
444   FileMapRegion* r = FileMapInfo::current_info()->region_at(MetaspaceShared::hp);
445   if (r->mapped_base() != nullptr && r->has_ptrmap()) {
446     log_info(cds, heap)("Patching native pointers in heap region");
447     BitMapView bm = r->ptrmap_view();
448     PatchNativePointers patcher((Metadata**)r->mapped_base());
449     bm.iterate(&patcher);
450   }
451 }
452 #endif // INCLUDE_CDS_JAVA_HEAP
< prev index next >