00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.4 $ */ 00002 /* Copyright (c) 2006, Sun Microsystems, Inc. 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 00006 following conditions are met: 00007 00008 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 00010 disclaimer in the documentation and/or other materials provided with the distribution. 00011 * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 00012 from this software without specific prior written permission. 00013 00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00020 00021 00022 */ 00023 00024 00025 # include "incls/_precompiled.incl" 00026 # include "incls/_snapshot.cpp.incl" 00027 00028 void SnapshotDesc::read_header() { 00029 read_revision(); 00030 read_sizes(); 00031 } 00032 00033 void SnapshotDesc::write_header() { 00034 write_revision(); 00035 write_sizes(); 00036 } 00037 00038 void SnapshotDesc::read_sizes() { 00039 00040 } 00041 00042 void SnapshotDesc::write_sizes() { 00043 00044 } 00045 00046 static const char* revision_format = "Delta snapshot revision: %d.%d\n"; 00047 00048 void SnapshotDesc::read_revision() { 00049 fprintf(file, revision_format, 00050 Universe::major_version(), Universe::snapshot_version()); 00051 } 00052 00053 void SnapshotDesc::write_revision() { 00054 int major, snap; 00055 if (fscanf(file, revision_format, &major, &snap) != 2) 00056 error("reading revision"); 00057 if (Universe::major_version() != major) 00058 error("major revision number conflict"); 00059 if (Universe::snapshot_version() != snap) 00060 error("snapshot revision number conflict"); 00061 } 00062 00063 class ReadClosure : public OopClosure { 00064 void do_oop(oop* o) { 00065 00066 } 00067 SnapshotDesc* s; 00068 public: 00069 ReadClosure(SnapshotDesc* s) { this->s = s; } 00070 }; 00071 00072 class WriteClosure : public OopClosure { 00073 void do_oop(oop* o) { 00074 fprintf(s->file, "0x%lx\n", o); 00075 } 00076 SnapshotDesc* s; 00077 public: 00078 WriteClosure(SnapshotDesc* s) { this->s = s; } 00079 }; 00080 00081 void SnapshotDesc::read_roots() { 00082 ReadClosure blk(this); 00083 Universe::root_iterate(&blk); 00084 } 00085 00086 void SnapshotDesc::write_roots() { 00087 WriteClosure blk(this); 00088 Universe::root_iterate(&blk); 00089 } 00090 00091 void SnapshotDesc::read_spaces() { 00092 00093 } 00094 00095 void SnapshotDesc::write_spaces() { 00096 00097 } 00098 00099 void SnapshotDesc::read_zone() { 00100 // Not implemented yet 00101 } 00102 00103 void SnapshotDesc::write_zone() { 00104 // Not implemented yet 00105 } 00106 00107 void SnapshotDesc::read_from(char* name) { 00108 read_header(); 00109 read_spaces(); 00110 read_roots(); 00111 read_zone(); 00112 } 00113 00114 void SnapshotDesc::write_on(char* name) { 00115 write_header(); 00116 write_spaces(); 00117 write_roots(); 00118 write_zone(); 00119 } 00120 00121 void SnapshotDesc::error(char* msg) { 00122 fatal(msg); 00123 } 00124 00125 symbolOop SnapshotDesc::error_symbol() { 00126 return NULL; 00127 }