< prev index next >

src/hotspot/share/memory/metaspaceShared.cpp

Print this page




1895   ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1896   oop* p = cache->get(obj);
1897   if (p != NULL) {
1898     return *p;
1899   } else {
1900     return NULL;
1901   }
1902 }
1903 
1904 oop MetaspaceShared::archive_heap_object(oop obj, Thread* THREAD) {
1905   assert(DumpSharedSpaces, "dump-time only");
1906 
1907   oop ao = find_archived_heap_object(obj);
1908   if (ao != NULL) {
1909     // already archived
1910     return ao;
1911   }
1912 
1913   int len = obj->size();
1914   if (G1CollectedHeap::heap()->is_archive_alloc_too_large(len)) {


1915     return NULL;
1916   }
1917 
1918   int hash = obj->identity_hash();
1919   oop archived_oop = (oop)G1CollectedHeap::heap()->archive_mem_allocate(len);
1920   if (archived_oop != NULL) {
1921     Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)archived_oop, len);
1922     relocate_klass_ptr(archived_oop);
1923     ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1924     cache->put(obj, archived_oop);
1925   }
1926   log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
1927                        p2i(obj), p2i(archived_oop));





1928   return archived_oop;
1929 }
1930 
1931 oop MetaspaceShared::materialize_archived_object(oop obj) {
1932   if (obj != NULL) {
1933     return G1CollectedHeap::heap()->materialize_archived_object(obj);
1934   }
1935   return NULL;
1936 }
1937 
1938 void MetaspaceShared::archive_klass_objects(Thread* THREAD) {
1939   int i;
1940   for (i = 0; i < _global_klass_objects->length(); i++) {
1941     Klass* k = _global_klass_objects->at(i);
1942 
1943     // archive mirror object
1944     java_lang_Class::archive_mirror(k, CHECK);
1945 
1946     // archive the resolved_referenes array
1947     if (k->is_instance_klass()) {




1895   ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1896   oop* p = cache->get(obj);
1897   if (p != NULL) {
1898     return *p;
1899   } else {
1900     return NULL;
1901   }
1902 }
1903 
1904 oop MetaspaceShared::archive_heap_object(oop obj, Thread* THREAD) {
1905   assert(DumpSharedSpaces, "dump-time only");
1906 
1907   oop ao = find_archived_heap_object(obj);
1908   if (ao != NULL) {
1909     // already archived
1910     return ao;
1911   }
1912 
1913   int len = obj->size();
1914   if (G1CollectedHeap::heap()->is_archive_alloc_too_large(len)) {
1915     log_debug(cds, heap)("Cannot archive, object (" PTR_FORMAT ") is too large: " SIZE_FORMAT,
1916                          p2i(obj), (size_t)obj->size());
1917     return NULL;
1918   }
1919 
1920   int hash = obj->identity_hash();
1921   oop archived_oop = (oop)G1CollectedHeap::heap()->archive_mem_allocate(len);
1922   if (archived_oop != NULL) {
1923     Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)archived_oop, len);
1924     relocate_klass_ptr(archived_oop);
1925     ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1926     cache->put(obj, archived_oop);

1927     log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
1928                          p2i(obj), p2i(archived_oop));
1929   } else {
1930     tty->print("Cannot allocate space for object " PTR_FORMAT " in archived heap region",
1931                p2i(obj));
1932     vm_exit(1);
1933   }
1934   return archived_oop;
1935 }
1936 
1937 oop MetaspaceShared::materialize_archived_object(oop obj) {
1938   if (obj != NULL) {
1939     return G1CollectedHeap::heap()->materialize_archived_object(obj);
1940   }
1941   return NULL;
1942 }
1943 
1944 void MetaspaceShared::archive_klass_objects(Thread* THREAD) {
1945   int i;
1946   for (i = 0; i < _global_klass_objects->length(); i++) {
1947     Klass* k = _global_klass_objects->at(i);
1948 
1949     // archive mirror object
1950     java_lang_Class::archive_mirror(k, CHECK);
1951 
1952     // archive the resolved_referenes array
1953     if (k->is_instance_klass()) {


< prev index next >