src/share/vm/memory/filemap.hpp

Fri, 23 Mar 2012 11:16:05 -0400

author
coleenp
date
Fri, 23 Mar 2012 11:16:05 -0400
changeset 3682
fc9d8850ab8b
parent 2314
f95d63e2154a
child 3900
d2a62e0f25eb
permissions
-rw-r--r--

7150058: Allocate symbols from null boot loader to an arena for NMT
Summary: Move symbol allocation to an arena so NMT doesn't have to track them at startup.
Reviewed-by: never, kamg, zgu

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_MEMORY_FILEMAP_HPP
stefank@2314 26 #define SHARE_VM_MEMORY_FILEMAP_HPP
stefank@2314 27
stefank@2314 28 #include "memory/compactingPermGenGen.hpp"
stefank@2314 29 #include "memory/space.hpp"
stefank@2314 30
duke@435 31 // Layout of the file:
duke@435 32 // header: dump of archive instance plus versioning info, datestamp, etc.
duke@435 33 // [magic # = 0xF00BABA2]
duke@435 34 // ... padding to align on page-boundary
duke@435 35 // read-write space from CompactingPermGenGen
duke@435 36 // read-only space from CompactingPermGenGen
duke@435 37 // misc data (block offset table, string table, symbols, dictionary, etc.)
duke@435 38 // tag(666)
duke@435 39
duke@435 40 static const int JVM_SHARED_JARS_MAX = 128;
duke@435 41 static const int JVM_SPACENAME_MAX = 128;
duke@435 42 static const int JVM_IDENT_MAX = 256;
duke@435 43 static const int JVM_ARCH_MAX = 12;
duke@435 44
duke@435 45
duke@435 46
duke@435 47 class FileMapInfo : public CHeapObj {
duke@435 48 private:
duke@435 49 enum {
duke@435 50 _invalid_version = -1,
duke@435 51 _current_version = 1
duke@435 52 };
duke@435 53
duke@435 54 bool _file_open;
duke@435 55 int _fd;
duke@435 56 long _file_offset;
duke@435 57
duke@435 58 // FileMapHeader describes the shared space data in the file to be
duke@435 59 // mapped. This structure gets written to a file. It is not a class, so
duke@435 60 // that the compilers don't add any compiler-private data to it.
duke@435 61
duke@435 62 struct FileMapHeader {
duke@435 63 int _magic; // identify file type.
duke@435 64 int _version; // (from enum, above.)
duke@435 65 size_t _alignment; // how shared archive should be aligned
duke@435 66
duke@435 67 struct space_info {
duke@435 68 int _file_offset; // sizeof(this) rounded to vm page size
duke@435 69 char* _base; // copy-on-write base address
duke@435 70 size_t _capacity; // for validity checking
duke@435 71 size_t _used; // for setting space top on read
duke@435 72 bool _read_only; // read only space?
duke@435 73 bool _allow_exec; // executable code in space?
duke@435 74 } _space[CompactingPermGenGen::n_regions];
duke@435 75
duke@435 76 // The following fields are all sanity checks for whether this archive
duke@435 77 // will function correctly with this JVM and the bootclasspath it's
duke@435 78 // invoked with.
duke@435 79 char _arch[JVM_ARCH_MAX]; // architecture
duke@435 80 char _jvm_ident[JVM_IDENT_MAX]; // identifier for jvm
duke@435 81 int _num_jars; // Number of jars in bootclasspath
duke@435 82
duke@435 83 // Per jar file data: timestamp, size.
duke@435 84
duke@435 85 struct {
duke@435 86 time_t _timestamp; // jar timestamp.
duke@435 87 long _filesize; // jar file size.
duke@435 88 } _jar[JVM_SHARED_JARS_MAX];
duke@435 89 } _header;
duke@435 90 const char* _full_path;
duke@435 91
duke@435 92 static FileMapInfo* _current_info;
duke@435 93
duke@435 94 bool init_from_file(int fd);
duke@435 95 void align_file_position();
duke@435 96
duke@435 97 public:
duke@435 98 FileMapInfo() {
duke@435 99 _file_offset = 0;
duke@435 100 _file_open = false;
duke@435 101 _header._version = _invalid_version;
duke@435 102 }
duke@435 103
duke@435 104 static int current_version() { return _current_version; }
duke@435 105 void populate_header(size_t alignment);
duke@435 106 bool validate();
duke@435 107 void invalidate();
duke@435 108 int version() { return _header._version; }
duke@435 109 size_t alignment() { return _header._alignment; }
duke@435 110 size_t space_capacity(int i) { return _header._space[i]._capacity; }
duke@435 111 char* region_base(int i) { return _header._space[i]._base; }
duke@435 112 struct FileMapHeader* header() { return &_header; }
duke@435 113
duke@435 114 static void set_current_info(FileMapInfo* info) { _current_info = info; }
duke@435 115 static FileMapInfo* current_info() { return _current_info; }
duke@435 116 static void assert_mark(bool check);
duke@435 117
duke@435 118 // File manipulation.
duke@435 119 bool initialize();
duke@435 120 bool open_for_read();
duke@435 121 void open_for_write();
duke@435 122 void write_header();
duke@435 123 void write_space(int i, CompactibleSpace* space, bool read_only);
duke@435 124 void write_region(int region, char* base, size_t size,
duke@435 125 size_t capacity, bool read_only, bool allow_exec);
duke@435 126 void write_bytes(const void* buffer, int count);
duke@435 127 void write_bytes_aligned(const void* buffer, int count);
duke@435 128 bool map_space(int i, ReservedSpace rs, ContiguousSpace *space);
duke@435 129 char* map_region(int i, ReservedSpace rs);
duke@435 130 char* map_region(int i, bool address_must_match);
duke@435 131 void unmap_region(int i);
duke@435 132 void close();
duke@435 133 bool is_open() { return _file_open; }
duke@435 134
duke@435 135 // JVM/TI RedefineClasses() support:
duke@435 136 // Remap the shared readonly space to shared readwrite, private.
duke@435 137 bool remap_shared_readonly_as_readwrite();
duke@435 138
duke@435 139 // Errors.
duke@435 140 static void fail_stop(const char *msg, ...);
duke@435 141 void fail_continue(const char *msg, ...);
duke@435 142
duke@435 143 // Return true if given address is in the mapped shared space.
duke@435 144 bool is_in_shared_space(const void* p);
duke@435 145 };
stefank@2314 146
stefank@2314 147 #endif // SHARE_VM_MEMORY_FILEMAP_HPP

mercurial