< prev index next >

src/hotspot/share/cds/heapShared.cpp

Print this page

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

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