filemap.cpp revision 605
3261N/A * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. 2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A#
include "incls/_precompiled.incl" 0N/A#
ifndef O_BINARY // if defined (Win32) use binary files. 2157N/A// Complain and stop. All error conditions occurring during the writing of 2157N/A// an archive file should stop the process. Unrecoverable errors during 2157N/A// the reading of the archive file should stop the process. 2157N/A // This occurs very early during initialization: tty is not initialized. 2157N/A "An error has occurred while processing the" 2157N/A " shared archive file.\n");
// Complain and continue. Recoverable errors during the reading of the // archive file may continue (with sharing disabled). // If we continue, then disable shared spaces and close the file. // Fill in the fileMapInfo structure with data about this VM instance. // The following fields are for sanity checks for whether this archive // will function correctly with this JVM and the bootclasspath it's // JVM version string ... changes on each build. fail_stop(
"JVM Ident field for shared archive is too long" // Build checks on classpath and jar files // Jar file - record timestamp and file size. // If we can't access a jar file in the boot path, then we can't // make assumptions about where classes get loaded from. // If directories appear in boot classpath, they must be empty to // avoid having to verify each individual class file. // Read the FileMapInfo information from the file. // Read the FileMapInfo information from the file. // Not locating the shared archive is ok. // Write the FileMapInfo information to the file. // Remove the existing file in case another process has it open. // Write the header to the file, seek to the next allocation boundary. // Dump shared spaces to file. tty->
print_cr(
"Shared file region %d: 0x%x bytes, addr 0x%x," // Dump bytes to file -- at the current file position. // It is dangerous to leave the corrupted shared archive file around, // close and remove the file. See bug 6372906. // Align file position to an allocation unit boundary. // Seek one byte back from the target and write a byte to insure // that the written file is the correct length. // Dump bytes to file -- at the current file position. // Close the shared archive file. This does NOT unmap mapped regions. fail_stop(
"Unable to close the shared archive file.");
// Memory map a shared space from the archive file. // JVM/TI RedefineClasses() support: // Remap the shared readonly space to shared readwrite, private. // the space is already readwrite so we are done fail_continue(
"Unable to remap shared readonly space at required address.");
// Memory map a region in the address space. // Memory map a region in the address space. fail_continue(
"Unable to map shared space at required address.");
si->
_base =
base;
// save mapped address for unmapping. // Unmap a memory region in the address space. fail_stop(
"Mark mismatch while restoring from shared file.",
NULL);
// Open the shared archive file, read and validate the header // information (version, boot classpath, etc.). If initialization // fails, shared spaces are disabled and the file is closed. [See fail_continue(
"The shared archive file has a bad magic number.");
fail_continue(
"The shared archive file was created by a different" " version or build of HotSpot.");
// Cannot verify interpreter yet, as it can only be created after the GC // heap has been initialized. // Build checks on classpath and jar files // Jar file - verify timestamp and file size. " the shared archive file.");
// If directories appear in boot classpath, they must be empty to // avoid having to verify each individual class file. " less than the number the shared archive was created with.");
// The following method is provided to see whether a given pointer // falls in the mapped shared space. // True if the p is within the mapped shared space, otherwise, false.