[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/igc 55670e01d0a: Give string data objects a header
From: |
Pip Cet |
Subject: |
scratch/igc 55670e01d0a: Give string data objects a header |
Date: |
Sat, 20 Jul 2024 14:18:26 -0400 (EDT) |
branch: scratch/igc
commit 55670e01d0ac94f8eda1563f1d2388b63b26c564
Author: Pip Cet <pipcet@protonmail.com>
Commit: Pip Cet <pipcet@protonmail.com>
Give string data objects a header
This excludes C strings, which MPS ignores as they're not in
MPS-managed memory.
* src/igc.c (fix_string): Account for string data header.
(alloc_string_data): Allocate as struct Lisp_String_Data.
* src/pdumper.c (dump_cold_string): Assume the string data is preceded
by a header, which we dump.
---
src/igc.c | 12 ++++++++----
src/pdumper.c | 12 ++++++++++--
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/igc.c b/src/igc.c
index 7cdd665770a..6f7aabf2523 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -1544,7 +1544,10 @@ fix_string (mps_ss_t ss, struct Lisp_String *s)
{
MPS_SCAN_BEGIN (ss)
{
- IGC_FIX12_RAW (ss, &s->u.s.data);
+ struct Lisp_String_Data *ptr =
+ (void *) (s->u.s.data - sizeof (*ptr));
+ IGC_FIX12_RAW (ss, &ptr);
+ s->u.s.data = ptr->data;
IGC_FIX12_RAW (ss, &s->u.s.intervals);
}
MPS_SCAN_END (ss);
@@ -3814,9 +3817,10 @@ igc_make_float (double val)
static unsigned char *
alloc_string_data (size_t nbytes, bool clear)
{
- unsigned char *data = alloc (nbytes + 1, IGC_OBJ_STRING_DATA);
- data[nbytes] = 0;
- return data;
+ struct Lisp_String_Data *data =
+ alloc (sizeof (*data) + nbytes + 1, IGC_OBJ_STRING_DATA);
+ data->data[nbytes] = 0;
+ return data->data;
}
void *
diff --git a/src/pdumper.c b/src/pdumper.c
index 1d96220348a..be3d6f1c6a4 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -3538,14 +3538,22 @@ dump_cold_string (struct dump_context *ctx, Lisp_Object
string)
eassert (total_size > 0);
# ifdef HAVE_MPS
+ struct Lisp_String_Data *data = (struct Lisp_String_Data *)
+ (XSTRING (string)->u.s.data - sizeof (*data));
dump_align_output (ctx, DUMP_ALIGNMENT);
- dump_igc_start_obj (ctx, IGC_OBJ_STRING_DATA, XSTRING (string)->u.s.data);
-# endif
+ dump_igc_start_obj (ctx, IGC_OBJ_STRING_DATA, data);
+ dump_remember_fixup_ptr_raw
+ (ctx,
+ string_offset + dump_offsetof (struct Lisp_String, u.s.data),
+ ctx->offset + sizeof (*data));
+ dump_write (ctx, data, sizeof (*data) + total_size);
+# else
dump_remember_fixup_ptr_raw
(ctx,
string_offset + dump_offsetof (struct Lisp_String, u.s.data),
ctx->offset);
dump_write (ctx, XSTRING (string)->u.s.data, total_size);
+# endif
# ifdef HAVE_MPS
dump_igc_finish_obj (ctx);
# endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/igc 55670e01d0a: Give string data objects a header,
Pip Cet <=