< prev index next >

src/hotspot/share/memory/metaspaceShared.cpp

Print this page


1927   if (archived_oop != NULL) {
1928     Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)archived_oop, len);
1929     relocate_klass_ptr(archived_oop);
1930     ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1931     cache->put(obj, archived_oop);
1932     log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
1933                          p2i(obj), p2i(archived_oop));
1934   } else {
1935     log_error(cds, heap)(
1936       "Cannot allocate space for object " PTR_FORMAT " in archived heap region",
1937       p2i(obj));
1938     vm_exit(1);
1939   }
1940   return archived_oop;
1941 }
1942 
1943 oop MetaspaceShared::materialize_archived_object(narrowOop v) {
1944   assert(archive_heap_region_fixed(),
1945          "must be called after archive heap regions are fixed");
1946   if (!CompressedOops::is_null(v)) {
1947     oop obj = HeapShared::decode_with_archived_oop_encoding_mode(v);
1948     return G1CollectedHeap::heap()->materialize_archived_object(obj);
1949   }
1950   return NULL;
1951 }
1952 
1953 void MetaspaceShared::archive_klass_objects(Thread* THREAD) {
1954   int i;
1955   for (i = 0; i < _global_klass_objects->length(); i++) {
1956     Klass* k = _global_klass_objects->at(i);
1957 
1958     // archive mirror object
1959     java_lang_Class::archive_mirror(k, CHECK);
1960 
1961     // archive the resolved_referenes array
1962     if (k->is_instance_klass()) {
1963       InstanceKlass* ik = InstanceKlass::cast(k);
1964       ik->constants()->archive_resolved_references(THREAD);
1965     }
1966   }
1967 }


2004     *p = (u4)(uintx(obj));
2005   }
2006 
2007   void do_tag(int tag) {
2008     int old_tag;
2009     old_tag = (int)(intptr_t)nextPtr();
2010     // do_int(&old_tag);
2011     assert(tag == old_tag, "old tag doesn't match");
2012     FileMapInfo::assert_mark(tag == old_tag);
2013   }
2014 
2015   void do_oop(oop *p) {
2016     narrowOop o = (narrowOop)nextPtr();
2017     if (o == 0 || !MetaspaceShared::open_archive_heap_region_mapped()) {
2018       p = NULL;
2019     } else {
2020       assert(MetaspaceShared::is_heap_object_archiving_allowed(),
2021              "Archived heap object is not allowed");
2022       assert(MetaspaceShared::open_archive_heap_region_mapped(),
2023              "Open archive heap region is not mapped");
2024       *p = HeapShared::decode_with_archived_oop_encoding_mode(o);
2025     }
2026   }
2027 
2028   void do_region(u_char* start, size_t size) {
2029     assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
2030     assert(size % sizeof(intptr_t) == 0, "bad size");
2031     do_tag((int)size);
2032     while (size > 0) {
2033       *(intptr_t*)start = nextPtr();
2034       start += sizeof(intptr_t);
2035       size -= sizeof(intptr_t);
2036     }
2037   }
2038 
2039   bool reading() const { return true; }
2040 };
2041 
2042 // Return true if given address is in the misc data region
2043 bool MetaspaceShared::is_in_shared_region(const void* p, int idx) {
2044   return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_region(p, idx);




1927   if (archived_oop != NULL) {
1928     Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)archived_oop, len);
1929     relocate_klass_ptr(archived_oop);
1930     ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1931     cache->put(obj, archived_oop);
1932     log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
1933                          p2i(obj), p2i(archived_oop));
1934   } else {
1935     log_error(cds, heap)(
1936       "Cannot allocate space for object " PTR_FORMAT " in archived heap region",
1937       p2i(obj));
1938     vm_exit(1);
1939   }
1940   return archived_oop;
1941 }
1942 
1943 oop MetaspaceShared::materialize_archived_object(narrowOop v) {
1944   assert(archive_heap_region_fixed(),
1945          "must be called after archive heap regions are fixed");
1946   if (!CompressedOops::is_null(v)) {
1947     oop obj = HeapShared::decode_from_archive(v);
1948     return G1CollectedHeap::heap()->materialize_archived_object(obj);
1949   }
1950   return NULL;
1951 }
1952 
1953 void MetaspaceShared::archive_klass_objects(Thread* THREAD) {
1954   int i;
1955   for (i = 0; i < _global_klass_objects->length(); i++) {
1956     Klass* k = _global_klass_objects->at(i);
1957 
1958     // archive mirror object
1959     java_lang_Class::archive_mirror(k, CHECK);
1960 
1961     // archive the resolved_referenes array
1962     if (k->is_instance_klass()) {
1963       InstanceKlass* ik = InstanceKlass::cast(k);
1964       ik->constants()->archive_resolved_references(THREAD);
1965     }
1966   }
1967 }


2004     *p = (u4)(uintx(obj));
2005   }
2006 
2007   void do_tag(int tag) {
2008     int old_tag;
2009     old_tag = (int)(intptr_t)nextPtr();
2010     // do_int(&old_tag);
2011     assert(tag == old_tag, "old tag doesn't match");
2012     FileMapInfo::assert_mark(tag == old_tag);
2013   }
2014 
2015   void do_oop(oop *p) {
2016     narrowOop o = (narrowOop)nextPtr();
2017     if (o == 0 || !MetaspaceShared::open_archive_heap_region_mapped()) {
2018       p = NULL;
2019     } else {
2020       assert(MetaspaceShared::is_heap_object_archiving_allowed(),
2021              "Archived heap object is not allowed");
2022       assert(MetaspaceShared::open_archive_heap_region_mapped(),
2023              "Open archive heap region is not mapped");
2024       *p = HeapShared::decode_from_archive(o);
2025     }
2026   }
2027 
2028   void do_region(u_char* start, size_t size) {
2029     assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment");
2030     assert(size % sizeof(intptr_t) == 0, "bad size");
2031     do_tag((int)size);
2032     while (size > 0) {
2033       *(intptr_t*)start = nextPtr();
2034       start += sizeof(intptr_t);
2035       size -= sizeof(intptr_t);
2036     }
2037   }
2038 
2039   bool reading() const { return true; }
2040 };
2041 
2042 // Return true if given address is in the misc data region
2043 bool MetaspaceShared::is_in_shared_region(const void* p, int idx) {
2044   return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_region(p, idx);


< prev index next >