< prev index next >

src/hotspot/share/memory/heapShared.cpp

Print this page


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.inline.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/symbolTable.hpp"
  29 #include "classfile/systemDictionaryShared.hpp"
  30 #include "classfile/vmSymbols.hpp"

  31 #include "logging/log.hpp"
  32 #include "logging/logMessage.hpp"
  33 #include "logging/logStream.hpp"
  34 #include "memory/archiveUtils.hpp"
  35 #include "memory/filemap.hpp"
  36 #include "memory/heapShared.inline.hpp"
  37 #include "memory/iterator.inline.hpp"
  38 #include "memory/metadataFactory.hpp"
  39 #include "memory/metaspaceClosure.hpp"
  40 #include "memory/metaspaceShared.hpp"
  41 #include "memory/resourceArea.hpp"
  42 #include "memory/universe.hpp"
  43 #include "oops/compressedOops.inline.hpp"
  44 #include "oops/fieldStreams.inline.hpp"
  45 #include "oops/oop.inline.hpp"
  46 #include "runtime/fieldDescriptor.inline.hpp"
  47 #include "runtime/safepointVerifiers.hpp"
  48 #include "utilities/bitMap.inline.hpp"
  49 #if INCLUDE_G1GC
  50 #include "gc/g1/g1CollectedHeap.hpp"


 165   if (!CompressedOops::is_null(v)) {
 166     oop obj = HeapShared::decode_from_archive(v);
 167     return G1CollectedHeap::heap()->materialize_archived_object(obj);
 168   }
 169   return NULL;
 170 }
 171 
 172 void HeapShared::archive_klass_objects(Thread* THREAD) {
 173   GrowableArray<Klass*>* klasses = MetaspaceShared::collected_klasses();
 174   assert(klasses != NULL, "sanity");
 175   for (int i = 0; i < klasses->length(); i++) {
 176     Klass* k = klasses->at(i);
 177 
 178     // archive mirror object
 179     java_lang_Class::archive_mirror(k, CHECK);
 180 
 181     // archive the resolved_referenes array
 182     if (k->is_instance_klass()) {
 183       InstanceKlass* ik = InstanceKlass::cast(k);
 184       ik->constants()->archive_resolved_references(THREAD);



















 185     }
 186   }
 187 }
 188 
 189 void HeapShared::archive_java_heap_objects(GrowableArray<MemRegion> *closed,
 190                                            GrowableArray<MemRegion> *open) {
 191   if (!is_heap_object_archiving_allowed()) {
 192     log_info(cds)(
 193       "Archived java heap is not supported as UseG1GC, "
 194       "UseCompressedOops and UseCompressedClassPointers are required."
 195       "Current settings: UseG1GC=%s, UseCompressedOops=%s, UseCompressedClassPointers=%s.",
 196       BOOL_TO_STR(UseG1GC), BOOL_TO_STR(UseCompressedOops),
 197       BOOL_TO_STR(UseCompressedClassPointers));
 198     return;
 199   }
 200 
 201   G1HeapVerifier::verify_ready_for_archiving();
 202 
 203   {
 204     NoSafepointVerifier nsv;




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.inline.hpp"
  27 #include "classfile/stringTable.hpp"
  28 #include "classfile/symbolTable.hpp"
  29 #include "classfile/systemDictionaryShared.hpp"
  30 #include "classfile/vmSymbols.hpp"
  31 #include "gc/shared/gcLocker.hpp"
  32 #include "logging/log.hpp"
  33 #include "logging/logMessage.hpp"
  34 #include "logging/logStream.hpp"
  35 #include "memory/archiveUtils.hpp"
  36 #include "memory/filemap.hpp"
  37 #include "memory/heapShared.inline.hpp"
  38 #include "memory/iterator.inline.hpp"
  39 #include "memory/metadataFactory.hpp"
  40 #include "memory/metaspaceClosure.hpp"
  41 #include "memory/metaspaceShared.hpp"
  42 #include "memory/resourceArea.hpp"
  43 #include "memory/universe.hpp"
  44 #include "oops/compressedOops.inline.hpp"
  45 #include "oops/fieldStreams.inline.hpp"
  46 #include "oops/oop.inline.hpp"
  47 #include "runtime/fieldDescriptor.inline.hpp"
  48 #include "runtime/safepointVerifiers.hpp"
  49 #include "utilities/bitMap.inline.hpp"
  50 #if INCLUDE_G1GC
  51 #include "gc/g1/g1CollectedHeap.hpp"


 166   if (!CompressedOops::is_null(v)) {
 167     oop obj = HeapShared::decode_from_archive(v);
 168     return G1CollectedHeap::heap()->materialize_archived_object(obj);
 169   }
 170   return NULL;
 171 }
 172 
 173 void HeapShared::archive_klass_objects(Thread* THREAD) {
 174   GrowableArray<Klass*>* klasses = MetaspaceShared::collected_klasses();
 175   assert(klasses != NULL, "sanity");
 176   for (int i = 0; i < klasses->length(); i++) {
 177     Klass* k = klasses->at(i);
 178 
 179     // archive mirror object
 180     java_lang_Class::archive_mirror(k, CHECK);
 181 
 182     // archive the resolved_referenes array
 183     if (k->is_instance_klass()) {
 184       InstanceKlass* ik = InstanceKlass::cast(k);
 185       ik->constants()->archive_resolved_references(THREAD);
 186     }
 187   }
 188 }
 189 
 190 void HeapShared::run_gc() {
 191   if (is_heap_object_archiving_allowed()) {
 192     // Avoid fragmentation while archiving heap objects.
 193     // We do this inside a safepoint, so that no further allocation can happen after GC
 194     // has finished.
 195     if (GCLocker::is_active()) {
 196       // Just checking for safety ...
 197       // This should not happen during -Xshare:dump. If you see this, probably the Java core lib
 198       // has been modified such that JNI code is executed in some clean up threads after
 199       // we have finished class loading.
 200       log_warning(cds)("GC locker is held, unable to start extra compacting GC. This may produce suboptimal results.");
 201     } else {
 202       log_info(cds)("Run GC ...");
 203       Universe::heap()->collect_as_vm_thread(GCCause::_archive_time_gc);
 204       log_info(cds)("Run GC done");
 205     }
 206   }
 207 }
 208 
 209 void HeapShared::archive_java_heap_objects(GrowableArray<MemRegion> *closed,
 210                                            GrowableArray<MemRegion> *open) {
 211   if (!is_heap_object_archiving_allowed()) {
 212     log_info(cds)(
 213       "Archived java heap is not supported as UseG1GC, "
 214       "UseCompressedOops and UseCompressedClassPointers are required."
 215       "Current settings: UseG1GC=%s, UseCompressedOops=%s, UseCompressedClassPointers=%s.",
 216       BOOL_TO_STR(UseG1GC), BOOL_TO_STR(UseCompressedOops),
 217       BOOL_TO_STR(UseCompressedClassPointers));
 218     return;
 219   }
 220 
 221   G1HeapVerifier::verify_ready_for_archiving();
 222 
 223   {
 224     NoSafepointVerifier nsv;


< prev index next >