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