1 #ifdef USE_PRAGMA_IDENT_SRC
   2 #pragma ident "@(#)serialize.cpp        1.9 07/05/05 17:05:55 JVM"
   3 #endif
   4 /*
   5  * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  
  26  */
  27 
  28 # include "incls/_precompiled.incl"
  29 # include "incls/_serialize.cpp.incl"
  30 
  31 
  32 // Serialize out the block offset shared array for the shared spaces.
  33 
  34 void CompactingPermGenGen::serialize_bts(SerializeOopClosure* soc) {
  35   _ro_bts->serialize(soc, readonly_bottom, readonly_end);
  36   _rw_bts->serialize(soc, readwrite_bottom, readwrite_end);
  37 }
  38 
  39 
  40 // Read/write a data stream for restoring/preserving oop pointers and
  41 // miscellaneous data from/to the shared archive file.
  42 
  43 void CompactingPermGenGen::serialize_oops(SerializeOopClosure* soc) {
  44   int tag = 0;
  45   soc->do_tag(--tag);
  46 
  47   assert(!UseCompressedOops, "UseCompressedOops doesn't work with shared archive");
  48   // Verify the sizes of various oops in the system.
  49   soc->do_tag(sizeof(oopDesc));
  50   soc->do_tag(sizeof(instanceOopDesc));
  51   soc->do_tag(sizeof(methodOopDesc));
  52   soc->do_tag(sizeof(constMethodOopDesc));
  53   soc->do_tag(sizeof(methodDataOopDesc));
  54   soc->do_tag(arrayOopDesc::base_offset_in_bytes(T_BYTE));
  55   soc->do_tag(sizeof(constantPoolOopDesc));
  56   soc->do_tag(sizeof(constantPoolCacheOopDesc));
  57   soc->do_tag(objArrayOopDesc::base_offset_in_bytes(T_BYTE));
  58   soc->do_tag(typeArrayOopDesc::base_offset_in_bytes(T_BYTE));
  59   soc->do_tag(sizeof(symbolOopDesc));
  60   soc->do_tag(sizeof(klassOopDesc));
  61   soc->do_tag(sizeof(markOopDesc));
  62   soc->do_tag(sizeof(compiledICHolderOopDesc));
  63 
  64   // Dump the block offset table entries.
  65   GenCollectedHeap* gch = GenCollectedHeap::heap();
  66   CompactingPermGenGen* pg = (CompactingPermGenGen*)gch->perm_gen();
  67   pg->serialize_bts(soc);
  68   soc->do_tag(--tag);
  69   pg->ro_space()->serialize_block_offset_array_offsets(soc);
  70   soc->do_tag(--tag);
  71   pg->rw_space()->serialize_block_offset_array_offsets(soc);
  72   soc->do_tag(--tag);
  73 
  74   // Special case - this oop needed in oop->is_oop() assertions.
  75   soc->do_ptr((void**)&Universe::_klassKlassObj);
  76   soc->do_tag(--tag);
  77 
  78   // Dump/restore miscellaneous oops.
  79   Universe::oops_do(soc, true);
  80   soc->do_tag(--tag);
  81 
  82   vmSymbols::oops_do(soc, true);               soc->do_tag(--tag);
  83   CodeCache::oops_do(soc);                     soc->do_tag(--tag);
  84   soc->do_tag(666);
  85 }