< prev index next >

src/hotspot/share/cds/heapShared.cpp

Print this page

 272 }
 273 
 274 oop HeapShared::archive_object(oop obj) {
 275   assert(DumpSharedSpaces, "dump-time only");
 276 
 277   oop ao = find_archived_heap_object(obj);
 278   if (ao != NULL) {
 279     // already archived
 280     return ao;
 281   }
 282 
 283   int len = obj->size();
 284   if (G1CollectedHeap::heap()->is_archive_alloc_too_large(len)) {
 285     log_debug(cds, heap)("Cannot archive, object (" PTR_FORMAT ") is too large: " SIZE_FORMAT,
 286                          p2i(obj), (size_t)obj->size());
 287     return NULL;
 288   }
 289 
 290   oop archived_oop = cast_to_oop(G1CollectedHeap::heap()->archive_mem_allocate(len));
 291   if (archived_oop != NULL) {
 292     Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), cast_from_oop<HeapWord*>(archived_oop), len);
 293     // Reinitialize markword to remove age/marking/locking/etc.
 294     //
 295     // We need to retain the identity_hash, because it may have been used by some hashtables
 296     // in the shared heap. This also has the side effect of pre-initializing the
 297     // identity_hash for all shared objects, so they are less likely to be written
 298     // into during run time, increasing the potential of memory sharing.
 299     int hash_original = obj->identity_hash();
 300     archived_oop->set_mark(markWord::prototype().copy_set_hash(hash_original));
 301     assert(archived_oop->mark().is_unlocked(), "sanity");
 302 
 303     DEBUG_ONLY(int hash_archived = archived_oop->identity_hash());
 304     assert(hash_original == hash_archived, "Different hash codes: original %x, archived %x", hash_original, hash_archived);
 305 
 306     ArchivedObjectCache* cache = archived_object_cache();
 307     cache->put(obj, archived_oop);
 308     if (log_is_enabled(Debug, cds, heap)) {
 309       ResourceMark rm;
 310       log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT " : %s",
 311                            p2i(obj), p2i(archived_oop), obj->klass()->external_name());
 312     }

 272 }
 273 
 274 oop HeapShared::archive_object(oop obj) {
 275   assert(DumpSharedSpaces, "dump-time only");
 276 
 277   oop ao = find_archived_heap_object(obj);
 278   if (ao != NULL) {
 279     // already archived
 280     return ao;
 281   }
 282 
 283   int len = obj->size();
 284   if (G1CollectedHeap::heap()->is_archive_alloc_too_large(len)) {
 285     log_debug(cds, heap)("Cannot archive, object (" PTR_FORMAT ") is too large: " SIZE_FORMAT,
 286                          p2i(obj), (size_t)obj->size());
 287     return NULL;
 288   }
 289 
 290   oop archived_oop = cast_to_oop(G1CollectedHeap::heap()->archive_mem_allocate(len));
 291   if (archived_oop != NULL) {
 292     obj->copy_disjoint(cast_from_oop<HeapWord*>(archived_oop), len);
 293     // Reinitialize markword to remove age/marking/locking/etc.
 294     //
 295     // We need to retain the identity_hash, because it may have been used by some hashtables
 296     // in the shared heap. This also has the side effect of pre-initializing the
 297     // identity_hash for all shared objects, so they are less likely to be written
 298     // into during run time, increasing the potential of memory sharing.
 299     int hash_original = obj->identity_hash();
 300     archived_oop->set_mark(markWord::prototype().copy_set_hash(hash_original));
 301     assert(archived_oop->mark().is_unlocked(), "sanity");
 302 
 303     DEBUG_ONLY(int hash_archived = archived_oop->identity_hash());
 304     assert(hash_original == hash_archived, "Different hash codes: original %x, archived %x", hash_original, hash_archived);
 305 
 306     ArchivedObjectCache* cache = archived_object_cache();
 307     cache->put(obj, archived_oop);
 308     if (log_is_enabled(Debug, cds, heap)) {
 309       ResourceMark rm;
 310       log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT " : %s",
 311                            p2i(obj), p2i(archived_oop), obj->klass()->external_name());
 312     }
< prev index next >