Skip to content

Commit dea933a

Browse files
[metadata] Add #JTD heap MonoImage:minimal_delta bit (#42137)
The presence of the heap indicates that it's a minimal delta image (where the heaps are meant to be appended to the previous heaps), as opposed to a full delta image (where the heap in the delta image contains the previous and the new data) --- Also add `MONO_TRACE_METADATA_UPDATE` (set `MONO_LOG_MASK` to `metadata-update`) for tracing Co-authored-by: lambdageek <lambdageek@users.noreply.github.com>
1 parent f404c54 commit dea933a

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

src/mono/mono/metadata/image.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,13 @@ load_metadata_ptrs (MonoImage *image, MonoCLIImageInfo *iinfo)
527527
image->heap_pdb.data = image->raw_metadata + read32 (ptr);
528528
image->heap_pdb.size = read32 (ptr + 4);
529529
ptr += 8 + 5;
530+
} else if (strncmp (ptr + 8, "#JTD", 5) == 0) {
531+
// See https://github.com/dotnet/runtime/blob/110282c71b3f7e1f91ea339953f4a0eba362a62c/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/MetadataReader.cs#L165-L175
532+
// skip read32(ptr) and read32(ptr + 4)
533+
// ignore the content of this stream
534+
image->minimal_delta = TRUE;
535+
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_METADATA_UPDATE, "Image '%s' has a minimal delta marker", image->name);
536+
ptr += 8 + 5;
530537
} else {
531538
g_message ("Unknown heap type: %s\n", ptr + 8);
532539
ptr += 8 + strlen (ptr + 8) + 1;

src/mono/mono/metadata/metadata-internals.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,9 @@ struct _MonoImage {
389389
/* Whenever this image is considered as platform code for the CoreCLR security model */
390390
guint8 core_clr_platform_code : 1;
391391

392+
/* Whether a #JTD stream was present. Indicates that this image was a minimal delta and its heaps only include the new heap entries */
393+
guint8 minimal_delta : 1;
394+
392395
/* The path to the file for this image or an arbitrary name for images loaded from data. */
393396
char *name;
394397

src/mono/mono/utils/mono-logger-internals.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ typedef enum {
2929
MONO_TRACE_TAILCALL = 1 << 16,
3030
MONO_TRACE_PROFILER = 1 << 17,
3131
MONO_TRACE_TIERED = 1 << 18,
32-
MONO_TRACE_QCALL = 1 << 19
32+
MONO_TRACE_QCALL = 1 << 19,
33+
MONO_TRACE_METADATA_UPDATE = 1 << 20,
3334
} MonoTraceMask;
3435

3536
MONO_BEGIN_DECLS

src/mono/mono/utils/mono-logger.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ mono_trace_set_mask_string (const char *value)
316316
{ "profiler", MONO_TRACE_PROFILER },
317317
{ "tiered", MONO_TRACE_TIERED },
318318
{ "qcall", MONO_TRACE_QCALL },
319+
{ "metadata-update", MONO_TRACE_METADATA_UPDATE },
319320
{ "all", (MonoTraceMask)~0 }, // FIXMEcxx there is a better way -- operator overloads of enums
320321
{ NULL, (MonoTraceMask)0 },
321322
};

0 commit comments

Comments
 (0)