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_ARCHIVEBUILDER_HPP
26 #define SHARE_CDS_ARCHIVEBUILDER_HPP
27
28 #include "cds/archiveUtils.hpp"
29 #include "cds/dumpAllocStats.hpp"
30 #include "memory/metaspaceClosure.hpp"
31 #include "oops/array.hpp"
32 #include "oops/klass.hpp"
33 #include "runtime/os.hpp"
34 #include "utilities/bitMap.hpp"
35 #include "utilities/growableArray.hpp"
36 #include "utilities/resizeableResourceHash.hpp"
37 #include "utilities/resourceHash.hpp"
38
39 struct ArchiveHeapOopmapInfo;
40 class CHeapBitMap;
41 class FileMapInfo;
42 class Klass;
43 class MemRegion;
44 class Symbol;
45
46 // Metaspace::allocate() requires that all blocks must be aligned with KlassAlignmentInBytes.
47 // We enforce the same alignment rule in blocks allocated from the shared space.
48 const int SharedSpaceObjectAlignment = KlassAlignmentInBytes;
49
50 // Overview of CDS archive creation (for both static and dynamic dump):
51 //
52 // [1] Load all classes (static dump: from the classlist, dynamic dump: as part of app execution)
53 // [2] Allocate "output buffer"
54 // [3] Copy contents of the 2 "core" regions (rw/ro) into the output buffer.
55 // - allocate the cpp vtables in rw (static dump only)
56 // - memcpy the MetaspaceObjs into rw/ro:
57 // dump_rw_region();
58 // dump_ro_region();
59 // - fix all the pointers in the MetaspaceObjs to point to the copies
60 // relocate_metaspaceobj_embedded_pointers()
61 // [4] Copy symbol table, dictionary, etc, into the ro region
62 // [5] Relocate all the pointers in rw/ro, so that the archive can be mapped to
63 // the "requested" location without runtime relocation. See relocate_to_requested()
64 class ArchiveBuilder : public StackObj {
65 protected:
66 DumpRegion* _current_dump_space;
67 address _buffer_bottom; // for writing the contents of rw/ro regions
68 address _last_verified_top;
|
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_ARCHIVEBUILDER_HPP
26 #define SHARE_CDS_ARCHIVEBUILDER_HPP
27
28 #include "cds/archiveUtils.hpp"
29 #include "cds/dumpAllocStats.hpp"
30 #include "memory/metaspaceClosure.hpp"
31 #include "memory/metaspace/metaspaceAlignment.hpp"
32 #include "oops/array.hpp"
33 #include "oops/klass.hpp"
34 #include "runtime/os.hpp"
35 #include "utilities/bitMap.hpp"
36 #include "utilities/growableArray.hpp"
37 #include "utilities/resizeableResourceHash.hpp"
38 #include "utilities/resourceHash.hpp"
39
40 struct ArchiveHeapOopmapInfo;
41 class CHeapBitMap;
42 class FileMapInfo;
43 class Klass;
44 class MemRegion;
45 class Symbol;
46
47 // CDS has three alignments to deal with:
48 // - SharedSpaceObjectAlignment, always 8 bytes: used for placing arbitrary structures.
49 // These may contain 64-bit members (not larger, we know that much). Therefore we
50 // need to use 64-bit alignment on both 32-bit and 64-bit platforms. We reuse metaspace
51 // minimal alignment for this, which follows the same logic.
52 // - With CompressedClassPointers=1, we need to store Klass structures with a large
53 // alignment (Lilliput specific narrow Klass pointer encoding) - KlassAlignmentInBytes.
54 // - Header data and tags are squeezed in with word alignment, which happens to be 4 bytes
55 // on 32-bit. See ReadClosure::do_xxx() and DumpRegion::append_intptr().
56 const int SharedSpaceObjectAlignment = metaspace::MetaspaceMinAlignmentBytes;
57
58 // standard alignment should be sufficient for storing 64-bit values.
59 STATIC_ASSERT(SharedSpaceObjectAlignment >= sizeof(uint64_t));
60
61 // Overview of CDS archive creation (for both static and dynamic dump):
62 //
63 // [1] Load all classes (static dump: from the classlist, dynamic dump: as part of app execution)
64 // [2] Allocate "output buffer"
65 // [3] Copy contents of the 2 "core" regions (rw/ro) into the output buffer.
66 // - allocate the cpp vtables in rw (static dump only)
67 // - memcpy the MetaspaceObjs into rw/ro:
68 // dump_rw_region();
69 // dump_ro_region();
70 // - fix all the pointers in the MetaspaceObjs to point to the copies
71 // relocate_metaspaceobj_embedded_pointers()
72 // [4] Copy symbol table, dictionary, etc, into the ro region
73 // [5] Relocate all the pointers in rw/ro, so that the archive can be mapped to
74 // the "requested" location without runtime relocation. See relocate_to_requested()
75 class ArchiveBuilder : public StackObj {
76 protected:
77 DumpRegion* _current_dump_space;
78 address _buffer_bottom; // for writing the contents of rw/ro regions
79 address _last_verified_top;
|