1 /* 2 * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_CDS_DYNAMICARCHIVE_HPP 26 #define SHARE_CDS_DYNAMICARCHIVE_HPP 27 28 #include "cds/filemap.hpp" 29 #include "classfile/compactHashtable.hpp" 30 #include "memory/allStatic.hpp" 31 #include "memory/memRegion.hpp" 32 #include "oops/array.hpp" 33 #include "oops/oop.hpp" 34 #include "utilities/exceptions.hpp" 35 #include "utilities/growableArray.hpp" 36 #include "utilities/macros.hpp" 37 38 #if INCLUDE_CDS 39 40 class DynamicArchiveHeader : public FileMapHeader { 41 friend class CDSConstants; 42 private: 43 int _base_header_crc; 44 int _base_region_crc[MetaspaceShared::n_regions]; 45 46 public: 47 int base_header_crc() const { return _base_header_crc; } 48 int base_region_crc(int i) const { 49 assert(is_valid_region(i), "must be"); 50 return _base_region_crc[i]; 51 } 52 53 void set_base_header_crc(int c) { _base_header_crc = c; } 54 void set_base_region_crc(int i, int c) { 55 assert(is_valid_region(i), "must be"); 56 _base_region_crc[i] = c; 57 } 58 void print(outputStream* st); 59 }; 60 61 class DynamicArchive : AllStatic { 62 private: 63 static GrowableArray<ObjArrayKlass*>* _array_klasses; 64 static Array<ObjArrayKlass*>* _dynamic_archive_array_klasses; 65 public: 66 static void check_for_dynamic_dump(); 67 static void dump_for_jcmd(const char* archive_name, TRAPS); 68 static void dump_at_exit(JavaThread* current, const char* archive_name); 69 static void dump_impl(bool jcmd_request, const char* archive_name, TRAPS); 70 static bool is_mapped() { return FileMapInfo::dynamic_info() != nullptr; } 71 static bool validate(FileMapInfo* dynamic_info); 72 static void dump_array_klasses(); 73 static void setup_array_klasses(); 74 static void append_array_klass(ObjArrayKlass* oak); 75 static void serialize_array_klasses(SerializeClosure* soc); 76 static void make_array_klasses_shareable(); 77 static void post_dump(); 78 static int num_array_klasses(); 79 }; 80 #endif // INCLUDE_CDS 81 #endif // SHARE_CDS_DYNAMICARCHIVE_HPP