[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/igc fd9709f58a8 3/6: Adjust dumping code to assume a header
From: |
Pip Cet |
Subject: |
scratch/igc fd9709f58a8 3/6: Adjust dumping code to assume a header |
Date: |
Sun, 21 Jul 2024 05:24:54 -0400 (EDT) |
branch: scratch/igc
commit fd9709f58a8713208ea185be9f3c0e3de97c17a4
Author: Pip Cet <pipcet@protonmail.com>
Commit: Pip Cet <pipcet@protonmail.com>
Adjust dumping code to assume a header
* src/igc.c (fix_charset_table):
(igc_dump_finish_obj):
(igc_on_pdump_loaded):
(igc_alloc_dump): Add or subtract IGC header sizes until things work.
* src/pdumper.c (dump_igc_start_obj): Add headers only when necesary.
(Fdump_emacs_portable): Adjust for header presence.
---
src/igc.c | 16 ++++++++--------
src/pdumper.c | 9 ++++++---
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/src/igc.c b/src/igc.c
index 1dfafd2433f..b5f4d18bcdd 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -1732,9 +1732,7 @@ static mps_res_t
fix_charset_table (mps_ss_t ss, struct charset *table, size_t nbytes)
{
igc_assert (table == charset_table);
- igc_assert (nbytes
- == (charset_table_size * sizeof (struct charset)
- + sizeof (struct igc_header)));
+ igc_assert (nbytes == (charset_table_size * sizeof (struct charset)));
MPS_SCAN_BEGIN (ss)
{
for (size_t i = 0, len = nbytes / sizeof (struct charset); i < len; i++)
@@ -4727,13 +4725,14 @@ igc_dump_finish_obj (void *client, enum igc_obj_type
type,
}
/* We are dumping some non-MPS object, e.g. a built-in symbol. */
- size_t client_size = end - base - sizeof *out;
+ size_t client_size = end - base;
size_t nbytes = alloc_size (client_size);
size_t hash;
type = (is_pure (client)
? pure_obj_type_and_hash (&hash, type, client)
: builtin_obj_type_and_hash (&hash, type, client));
- set_header (out, type, nbytes, hash);
+ if (type != IGC_OBJ_DUMPED_BIGNUM_DATA)
+ set_header (out, type, nbytes, hash);
return base + nbytes;
}
@@ -4805,6 +4804,7 @@ igc_on_pdump_loaded (void *dump_base, void *hot_start,
void *hot_end,
void *cold_start, void *cold_end,
void *cold_user_data_start, void *heap_end)
{
+ dump_base = (char *)dump_base - igc_header_size ();
igc_assert (global_igc->park_count > 0);
igc_assert (base_to_client (hot_start) == charset_table);
igc_assert (header_type ((struct igc_header *) hot_start)
@@ -4824,10 +4824,10 @@ igc_on_pdump_loaded (void *dump_base, void *hot_start,
void *hot_end,
igc_assert (header_type (h) == IGC_OBJ_INVALID);
igc_assert (obj_size (h)
- == sizeof *h + (uint8_t *)cold_end - (uint8_t *)dump_base);
+ == (uint8_t *)cold_end - (uint8_t *)dump_base);
igc_assert (discardable_size > 2 * sizeof *h);
/* Ignore dump_header */
- set_header (h, IGC_OBJ_PAD, sizeof *h + dump_header_size, 0);
+ set_header (h, IGC_OBJ_PAD, dump_header_size, 0);
/* Ignore discardable section */
set_header (hot_end, IGC_OBJ_PAD, discardable_size, 0);
/* Ignore relocs */
@@ -4863,7 +4863,7 @@ igc_alloc_dump (size_t nbytes)
set_header (block, IGC_OBJ_INVALID, block_size, 0);
}
while (!mps_commit (ap, block, block_size));
- return base_to_client (block);
+ return (char *) block + igc_header_size ();
}
bool
diff --git a/src/pdumper.c b/src/pdumper.c
index dc31bfdad65..996bdc79106 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -911,7 +911,9 @@ dump_igc_start_obj (struct dump_context *ctx, enum
igc_obj_type type,
ctx->igc_obj_dumped = (void *) in;
ctx->igc_type = type;
ctx->igc_base_offset = ctx->offset;
- if (ctx->flags.dump_object_contents)
+ if (ctx->flags.dump_object_contents &&
+ (type == IGC_OBJ_DUMPED_BYTES ||
+ type == IGC_OBJ_DUMPED_CODE_SPACE_MASKS))
{
/* This saving of obj_offset is Because of an assertion in
dump_write. */
@@ -4512,7 +4514,8 @@ types. */)
dump_align_output (ctx, DUMP_ALIGNMENT);
fprintf (stderr, "cold user data: %x\n", (unsigned)ctx->offset);
ctx->header.cold_user_data_start = ctx->offset;
- dump_igc_start_obj (ctx, IGC_OBJ_DUMPED_BYTES, &discardable_end);
+ union gc_header header = { 0 };
+ dump_igc_start_obj (ctx, IGC_OBJ_DUMPED_BYTES, &header);
# endif
/* dump_drain_user_remembered_data_cold needs to be after
@@ -4534,7 +4537,7 @@ types. */)
# ifdef HAVE_MPS
ctx->header.heap_end = ctx->offset;
dump_igc_check_object_starts (ctx);
- dump_igc_start_obj (ctx, IGC_OBJ_DUMPED_BYTES, &discardable_end);
+ dump_igc_start_obj (ctx, IGC_OBJ_DUMPED_BYTES, &header);
# endif
/* Make remembered modifications to the dump file itself. */
- scratch/igc updated (9a96b02bb51 -> 90e80a9a53e), Pip Cet, 2024/07/21
- scratch/igc 1551ac70793 4/6: Split up MPS fix functions by type, Pip Cet, 2024/07/21
- scratch/igc 47fa4bb6e97 1/6: Give byte allocations a header, Pip Cet, 2024/07/21
- scratch/igc 2c6e10f8351 5/6: Make client_to_base, base_to_client identity functions, Pip Cet, 2024/07/21
- scratch/igc 90e80a9a53e 6/6: Adjust igc.c code to header changes, Pip Cet, 2024/07/21
- scratch/igc fd9709f58a8 3/6: Adjust dumping code to assume a header,
Pip Cet <=
- scratch/igc 035fae58b1d 2/6: Allocate hash table vectors and object vectors as Lisp_Vectors, Pip Cet, 2024/07/21