Thu, 06 Mar 2014 09:08:18 +0100
8038399: Remove dead oop_iterate MemRegion variants from SharedHeap, Generation and Space classes
Reviewed-by: tschatzl, stefank
duke@435 | 1 | /* |
hseigel@5528 | 2 | * Copyright (c) 2003, 2013, 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 | |
coleenp@4037 | 28 | #include "memory/metaspaceShared.hpp" |
stefank@5863 | 29 | #include "memory/metaspace.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 | |
coleenp@4037 | 46 | class Metaspace; |
duke@435 | 47 | |
zgu@3900 | 48 | class FileMapInfo : public CHeapObj<mtInternal> { |
duke@435 | 49 | private: |
duke@435 | 50 | enum { |
duke@435 | 51 | _invalid_version = -1, |
duke@435 | 52 | _current_version = 1 |
duke@435 | 53 | }; |
duke@435 | 54 | |
duke@435 | 55 | bool _file_open; |
duke@435 | 56 | int _fd; |
duke@435 | 57 | long _file_offset; |
duke@435 | 58 | |
duke@435 | 59 | // FileMapHeader describes the shared space data in the file to be |
duke@435 | 60 | // mapped. This structure gets written to a file. It is not a class, so |
duke@435 | 61 | // that the compilers don't add any compiler-private data to it. |
duke@435 | 62 | |
duke@435 | 63 | struct FileMapHeader { |
duke@435 | 64 | int _magic; // identify file type. |
duke@435 | 65 | int _version; // (from enum, above.) |
duke@435 | 66 | size_t _alignment; // how shared archive should be aligned |
hseigel@4397 | 67 | int _obj_alignment; // value of ObjectAlignmentInBytes |
duke@435 | 68 | |
duke@435 | 69 | struct space_info { |
duke@435 | 70 | int _file_offset; // sizeof(this) rounded to vm page size |
duke@435 | 71 | char* _base; // copy-on-write base address |
duke@435 | 72 | size_t _capacity; // for validity checking |
duke@435 | 73 | size_t _used; // for setting space top on read |
duke@435 | 74 | bool _read_only; // read only space? |
duke@435 | 75 | bool _allow_exec; // executable code in space? |
coleenp@4037 | 76 | } _space[MetaspaceShared::n_regions]; |
duke@435 | 77 | |
duke@435 | 78 | // The following fields are all sanity checks for whether this archive |
duke@435 | 79 | // will function correctly with this JVM and the bootclasspath it's |
duke@435 | 80 | // invoked with. |
duke@435 | 81 | char _arch[JVM_ARCH_MAX]; // architecture |
duke@435 | 82 | char _jvm_ident[JVM_IDENT_MAX]; // identifier for jvm |
duke@435 | 83 | int _num_jars; // Number of jars in bootclasspath |
duke@435 | 84 | |
duke@435 | 85 | // Per jar file data: timestamp, size. |
duke@435 | 86 | |
duke@435 | 87 | struct { |
duke@435 | 88 | time_t _timestamp; // jar timestamp. |
duke@435 | 89 | long _filesize; // jar file size. |
duke@435 | 90 | } _jar[JVM_SHARED_JARS_MAX]; |
duke@435 | 91 | } _header; |
duke@435 | 92 | const char* _full_path; |
duke@435 | 93 | |
duke@435 | 94 | static FileMapInfo* _current_info; |
duke@435 | 95 | |
duke@435 | 96 | bool init_from_file(int fd); |
duke@435 | 97 | void align_file_position(); |
duke@435 | 98 | |
duke@435 | 99 | public: |
duke@435 | 100 | FileMapInfo() { |
duke@435 | 101 | _file_offset = 0; |
duke@435 | 102 | _file_open = false; |
duke@435 | 103 | _header._version = _invalid_version; |
duke@435 | 104 | } |
duke@435 | 105 | |
duke@435 | 106 | static int current_version() { return _current_version; } |
duke@435 | 107 | void populate_header(size_t alignment); |
duke@435 | 108 | bool validate(); |
duke@435 | 109 | void invalidate(); |
duke@435 | 110 | int version() { return _header._version; } |
duke@435 | 111 | size_t alignment() { return _header._alignment; } |
duke@435 | 112 | size_t space_capacity(int i) { return _header._space[i]._capacity; } |
duke@435 | 113 | char* region_base(int i) { return _header._space[i]._base; } |
duke@435 | 114 | struct FileMapHeader* header() { return &_header; } |
duke@435 | 115 | |
jprovino@4720 | 116 | static void set_current_info(FileMapInfo* info) { |
jprovino@4720 | 117 | CDS_ONLY(_current_info = info;) |
jprovino@4720 | 118 | } |
jprovino@4720 | 119 | |
jprovino@4720 | 120 | static FileMapInfo* current_info() { |
jprovino@4720 | 121 | CDS_ONLY(return _current_info;) |
jprovino@4720 | 122 | NOT_CDS(return NULL;) |
jprovino@4720 | 123 | } |
jprovino@4720 | 124 | |
duke@435 | 125 | static void assert_mark(bool check); |
duke@435 | 126 | |
duke@435 | 127 | // File manipulation. |
jprovino@4720 | 128 | bool initialize() NOT_CDS_RETURN_(false); |
duke@435 | 129 | bool open_for_read(); |
duke@435 | 130 | void open_for_write(); |
duke@435 | 131 | void write_header(); |
coleenp@4037 | 132 | void write_space(int i, Metaspace* space, bool read_only); |
duke@435 | 133 | void write_region(int region, char* base, size_t size, |
duke@435 | 134 | size_t capacity, bool read_only, bool allow_exec); |
duke@435 | 135 | void write_bytes(const void* buffer, int count); |
duke@435 | 136 | void write_bytes_aligned(const void* buffer, int count); |
coleenp@4037 | 137 | char* map_region(int i); |
duke@435 | 138 | void unmap_region(int i); |
duke@435 | 139 | void close(); |
duke@435 | 140 | bool is_open() { return _file_open; } |
coleenp@4037 | 141 | ReservedSpace reserve_shared_memory(); |
duke@435 | 142 | |
duke@435 | 143 | // JVM/TI RedefineClasses() support: |
duke@435 | 144 | // Remap the shared readonly space to shared readwrite, private. |
duke@435 | 145 | bool remap_shared_readonly_as_readwrite(); |
duke@435 | 146 | |
duke@435 | 147 | // Errors. |
duke@435 | 148 | static void fail_stop(const char *msg, ...); |
duke@435 | 149 | void fail_continue(const char *msg, ...); |
duke@435 | 150 | |
duke@435 | 151 | // Return true if given address is in the mapped shared space. |
jprovino@4720 | 152 | bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false); |
iklam@5329 | 153 | void print_shared_spaces() NOT_CDS_RETURN; |
hseigel@5528 | 154 | |
hseigel@5528 | 155 | static size_t shared_spaces_size() { |
hseigel@5528 | 156 | return align_size_up(SharedReadOnlySize + SharedReadWriteSize + |
hseigel@5528 | 157 | SharedMiscDataSize + SharedMiscCodeSize, |
hseigel@5528 | 158 | os::vm_allocation_granularity()); |
hseigel@5528 | 159 | } |
hseigel@5528 | 160 | |
hseigel@5528 | 161 | // Stop CDS sharing and unmap CDS regions. |
hseigel@5528 | 162 | static void stop_sharing_and_unmap(const char* msg); |
duke@435 | 163 | }; |
stefank@2314 | 164 | |
stefank@2314 | 165 | #endif // SHARE_VM_MEMORY_FILEMAP_HPP |