1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | // |
5 | // File: HotDataFormat.h |
6 | // |
7 | |
8 | // |
9 | // Format of the hot data stored in the hot stream. The format consists of several structures: |
10 | // * code:MetaData::HotMetaDataHeader, which contains reference to: |
11 | // * code:MetaData::HotTablesDirectory, which contains array of references to: |
12 | // * code:HotTableHeader |
13 | // * code:MetaData::HotHeapsDirectory, which contains array of code:MetaData::HotHeapsDirectoryEntry, |
14 | // each containig: |
15 | // * index of the heap code:HeapIndex and a reference to: |
16 | // * code:MetaData::HotHeapHeader, which contains reference to: |
17 | // * index table, which contains sorted array of represented hot indexes in the heap |
18 | // * value offsets table, which contains offsets of values for corresponding hot indexes in |
19 | // previous table |
20 | // * value heap, which contains the values (copied out) from the original cold heap |
21 | // |
22 | // ====================================================================================== |
23 | |
24 | #pragma once |
25 | |
26 | #include "external.h" |
27 | |
28 | // To avoid weird .h cycles, we have to include stgpool.h to get include of metamodelpub.h |
29 | #include <stgpool.h> |
30 | #include <metamodelpub.h> |
31 | |
32 | namespace MetaData |
33 | { |
34 | |
35 | // #HotMetaData |
36 | // To help with startup time, we create a section of metadata that is only that meta-data that was touched |
37 | // durring IBC profiling. Given an offset into a pool this checks if we have any hot data associated with |
38 | // it. If we do we return a pointer to it, otherwse we return NULL. |
39 | |
40 | #include <pshpack1.h> |
41 | |
42 | // -------------------------------------------------------------------------------------- |
43 | // |
44 | // Top level hot data header. |
45 | // Ends at the end of MetaData hot stream (i.e. starts at offset end-8). |
46 | // |
47 | struct |
48 | { |
49 | // Negative offset relative to the beginning of this structure. |
50 | // Points to the END (!!!) of code:HotTablesDirectory structure. |
51 | UINT32 ; |
52 | // Negative offset relative to the beginning of this structure. |
53 | // Points to the (start of) code:HotHeapsDirectory structure. |
54 | UINT32 ; |
55 | |
56 | }; // struct HotMetaDataHeader |
57 | |
58 | // -------------------------------------------------------------------------------------- |
59 | // |
60 | // This is the starting structure for hot data of tables. |
61 | // It's referenced (via reference to the end) from |
62 | // code:HotMetaDataHeader::m_nTablesDirectoryEnd_NegativeOffset. |
63 | // |
64 | struct HotTablesDirectory |
65 | { |
66 | // Magic number (code:#const_nMagic) for format verification. |
67 | UINT32 m_nMagic; |
68 | // Array of signed offsets (should have negative or 0 value) relative to the beginning of this structute |
69 | // for each MetaData table. |
70 | // Points to the (start of) code:HotTableHeader structure. |
71 | INT32 [TBL_COUNT]; |
72 | |
73 | //#const_nMagic |
74 | // Magic value "HOMD" in code:m_nMagic field. |
75 | static const UINT32 const_nMagic = 0x484f4e44; |
76 | |
77 | }; // struct HotTablesDirectory |
78 | |
79 | // -------------------------------------------------------------------------------------- |
80 | // |
81 | // Describes hot data in a table. |
82 | // Entry referenced (via reference to the start) from code:HotTablesDirectory::m_rgTableHeader_SignedOffset. |
83 | // |
84 | struct |
85 | { |
86 | UINT32 ; |
87 | // Can be 0 or sizeof(struct HotTableHeader) |
88 | UINT32 ; |
89 | // Can be 0 |
90 | UINT32 ; |
91 | UINT32 ; |
92 | UINT32 ; |
93 | UINT16 ; |
94 | |
95 | }; // struct HotTableHeader |
96 | |
97 | // -------------------------------------------------------------------------------------- |
98 | // |
99 | // This is the starting structure for hot data of heaps (string, blob, guid and user string heap). |
100 | // The directory is an array of code:HotHeapsDirectoryEntry structures. |
101 | // It's referenced from code:HotMetaDataHeader::m_nHeapsDirectoryStart_NegativeOffset. |
102 | // |
103 | struct HotHeapsDirectory |
104 | { |
105 | //code:HotHeapsDirectoryEntry m_rgEntries[*]; |
106 | |
107 | }; // struct HotHeapsDirectory |
108 | |
109 | // -------------------------------------------------------------------------------------- |
110 | // |
111 | // Describes one heap and its hot data. |
112 | // Entry in the hot heaps directory (code:HotHeapsDirectory). |
113 | // |
114 | struct HotHeapsDirectoryEntry |
115 | { |
116 | // Index of the represented heap code:HeapIndex. |
117 | UINT32 m_nHeapIndex; |
118 | // Negative offset relative to the beginning of this structure. |
119 | // Points to the (start of) code:HotHeapHeader structure. |
120 | UINT32 ; |
121 | |
122 | }; // struct HotHeapsDirectoryEntry |
123 | |
124 | // -------------------------------------------------------------------------------------- |
125 | // |
126 | // Describes hot data in a heap. |
127 | // It's referenced from code:HotHeapsDirectoryEntry::m_nHeapHeaderStart_NegativeOffset. |
128 | // |
129 | struct |
130 | { |
131 | // Negative offset relative to the beginning of this structure. |
132 | // Points to a (start of) table of indexes (UINT32). This table is sorted, so binary search can be |
133 | // performed. If an index is cached in hot data of this heap, then the index is present in this table |
134 | // of indexes. |
135 | UINT32 ; |
136 | // Negative offset relative to the beginning of this structure. |
137 | // Points to a (start of) table of value offsets (UINT32). This table contains value for each iteam in |
138 | // previous table of indexes. When an index is found in the previous table, then the value offset is |
139 | // stored in this table at the same index. |
140 | // The value offset is positive (!!!) offset relative to the start of heap values (see next member - |
141 | // code:m_nValueHeapStart_NegativeOffset) |
142 | UINT32 ; |
143 | // Negative offset relative to the beginning of this structure. |
144 | // Points to a (start of) values in the hot heap. This heap contains copies of values from the "normal" |
145 | // (cold) heap. The values in this heap have therefore the same encoding as the values in corresponding |
146 | // normal/cold heap. |
147 | // Offsets into this heap are stored in value offset table (code:m_nValueOffsetTableStart_NegativeOffset) |
148 | // as positive (!!!) offsets relative to the start of this hot value heap. |
149 | UINT32 ; |
150 | |
151 | }; // struct HotHeapHeader |
152 | |
153 | #include <poppack.h> |
154 | |
155 | }; // namespace MetaData |
156 | |