diff options
| author | Helmut Eller | 2024-06-17 19:47:04 +0200 |
|---|---|---|
| committer | Helmut Eller | 2026-02-12 18:51:50 +0100 |
| commit | df48f7efc61777804a342d22a79f55649bc306a3 (patch) | |
| tree | 8f64ea6e45f360a201f1ec2d9de10a386ede9f3f /src | |
| parent | f8a25d00ae45a3362b08a999026835fde85f6ef0 (diff) | |
| download | emacs-df48f7efc61777804a342d22a79f55649bc306a3.tar.gz emacs-df48f7efc61777804a342d22a79f55649bc306a3.zip | |
Don't dump lispfwd objects
The forwarding structs already exist in the data or bss section.
They are all created with DEFVAR_INT and similar macros. Instead
of creating new structs in the dump, create relocs to the data section.
* src/pdumper.c (dump_field_fwd): New.
(dump_blv, dump_symbol): Use it.
(dump_pre_dump_symbol): Don't dump fwd objects.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pdumper.c | 69 |
1 files changed, 47 insertions, 22 deletions
diff --git a/src/pdumper.c b/src/pdumper.c index 151c45b3348..bc3f3f3d63a 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -2383,6 +2383,51 @@ dump_fwd (struct dump_context *ctx, lispfwd fwd) | |||
| 2383 | } | 2383 | } |
| 2384 | } | 2384 | } |
| 2385 | 2385 | ||
| 2386 | static void | ||
| 2387 | dump_field_fwd (struct dump_context *ctx, void *out, const void *in_start, | ||
| 2388 | const lispfwd *in_field) | ||
| 2389 | { | ||
| 2390 | dump_field_emacs_ptr (ctx, out, in_start, in_field); | ||
| 2391 | switch (XFWDTYPE (*in_field)) | ||
| 2392 | { | ||
| 2393 | case Lisp_Fwd_Int: | ||
| 2394 | { | ||
| 2395 | const struct Lisp_Intfwd *fwd = in_field->fwdptr; | ||
| 2396 | dump_emacs_reloc_immediate_intmax_t (ctx, fwd->intvar, *fwd->intvar); | ||
| 2397 | } | ||
| 2398 | break; | ||
| 2399 | case Lisp_Fwd_Bool: | ||
| 2400 | { | ||
| 2401 | const struct Lisp_Boolfwd *fwd = in_field->fwdptr; | ||
| 2402 | dump_emacs_reloc_immediate_bool (ctx, fwd->boolvar, *fwd->boolvar); | ||
| 2403 | } | ||
| 2404 | break; | ||
| 2405 | case Lisp_Fwd_Obj: | ||
| 2406 | { | ||
| 2407 | const struct Lisp_Objfwd *fwd = in_field->fwdptr; | ||
| 2408 | if (NILP (Fgethash (dump_off_to_lisp (emacs_offset (fwd->objvar)), | ||
| 2409 | ctx->staticpro_table, Qnil))) | ||
| 2410 | dump_emacs_reloc_to_lv (ctx, fwd->objvar, *fwd->objvar); | ||
| 2411 | } | ||
| 2412 | break; | ||
| 2413 | case Lisp_Fwd_Kboard_Obj: | ||
| 2414 | break; | ||
| 2415 | case Lisp_Fwd_Buffer_Obj: | ||
| 2416 | { | ||
| 2417 | const struct Lisp_Buffer_Objfwd *fwd = in_field->fwdptr; | ||
| 2418 | dump_emacs_reloc_immediate (ctx, &fwd->type, &fwd->type, | ||
| 2419 | sizeof fwd->type); | ||
| 2420 | dump_emacs_reloc_immediate (ctx, &fwd->offset, &fwd->offset, | ||
| 2421 | sizeof fwd->offset); | ||
| 2422 | eassert (SYMBOLP (fwd->predicate)); | ||
| 2423 | /* FIXME: assumes symbols are represented as offsets from lispsym */ | ||
| 2424 | dump_emacs_reloc_immediate (ctx, &fwd->predicate, &fwd->predicate, | ||
| 2425 | sizeof fwd->predicate); | ||
| 2426 | } | ||
| 2427 | break; | ||
| 2428 | } | ||
| 2429 | } | ||
| 2430 | |||
| 2386 | static dump_off | 2431 | static dump_off |
| 2387 | dump_blv (struct dump_context *ctx, | 2432 | dump_blv (struct dump_context *ctx, |
| 2388 | const struct Lisp_Buffer_Local_Value *blv) | 2433 | const struct Lisp_Buffer_Local_Value *blv) |
| @@ -2397,14 +2442,12 @@ dump_blv (struct dump_context *ctx, | |||
| 2397 | if (blv->fwd.fwdptr) | 2442 | if (blv->fwd.fwdptr) |
| 2398 | { | 2443 | { |
| 2399 | eassert (XFWDTYPE (blv->fwd) != Lisp_Fwd_Buffer_Obj); | 2444 | eassert (XFWDTYPE (blv->fwd) != Lisp_Fwd_Buffer_Obj); |
| 2400 | dump_field_emacs_ptr (ctx, &out, blv, &blv->fwd.fwdptr); | 2445 | dump_field_fwd (ctx, &out, blv, &blv->fwd); |
| 2401 | } | 2446 | } |
| 2402 | dump_field_lv (ctx, &out, blv, &blv->where, WEIGHT_NORMAL); | 2447 | dump_field_lv (ctx, &out, blv, &blv->where, WEIGHT_NORMAL); |
| 2403 | dump_field_lv (ctx, &out, blv, &blv->defcell, WEIGHT_STRONG); | 2448 | dump_field_lv (ctx, &out, blv, &blv->defcell, WEIGHT_STRONG); |
| 2404 | dump_field_lv (ctx, &out, blv, &blv->valcell, WEIGHT_STRONG); | 2449 | dump_field_lv (ctx, &out, blv, &blv->valcell, WEIGHT_STRONG); |
| 2405 | dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); | 2450 | dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); |
| 2406 | if (blv->fwd.fwdptr) | ||
| 2407 | dump_fwd (ctx, blv->fwd); | ||
| 2408 | return offset; | 2451 | return offset; |
| 2409 | } | 2452 | } |
| 2410 | 2453 | ||
| @@ -2446,11 +2489,6 @@ dump_pre_dump_symbol (struct dump_context *ctx, struct Lisp_Symbol *symbol) | |||
| 2446 | dump_remember_symbol_aux (ctx, symbol_lv, | 2489 | dump_remember_symbol_aux (ctx, symbol_lv, |
| 2447 | dump_blv (ctx, symbol->u.s.val.blv)); | 2490 | dump_blv (ctx, symbol->u.s.val.blv)); |
| 2448 | break; | 2491 | break; |
| 2449 | case SYMBOL_FORWARDED: | ||
| 2450 | dump_fwd (ctx, symbol->u.s.val.fwd); | ||
| 2451 | dump_remember_symbol_aux (ctx, symbol_lv, | ||
| 2452 | emacs_offset (symbol->u.s.val.fwd.fwdptr)); | ||
| 2453 | break; | ||
| 2454 | default: | 2492 | default: |
| 2455 | break; | 2493 | break; |
| 2456 | } | 2494 | } |
| @@ -2515,11 +2553,7 @@ dump_symbol (struct dump_context *ctx, Lisp_Object object, | |||
| 2515 | dump_field_fixup_later (ctx, &out, symbol, &symbol->u.s.val.blv); | 2553 | dump_field_fixup_later (ctx, &out, symbol, &symbol->u.s.val.blv); |
| 2516 | break; | 2554 | break; |
| 2517 | case SYMBOL_FORWARDED: | 2555 | case SYMBOL_FORWARDED: |
| 2518 | /* This forwarding descriptor is in Emacs's core, but the symbol | 2556 | dump_field_fwd (ctx, &out, symbol, &symbol->u.s.val.fwd); |
| 2519 | is initialized at runtime. The next switch statement might | ||
| 2520 | dump this value if it hasn't already been dumped by | ||
| 2521 | dump_pre_dump_symbol. */ | ||
| 2522 | dump_field_emacs_ptr (ctx, &out, symbol, &symbol->u.s.val.fwd.fwdptr); | ||
| 2523 | break; | 2557 | break; |
| 2524 | 2558 | ||
| 2525 | default: | 2559 | default: |
| @@ -2541,15 +2575,6 @@ dump_symbol (struct dump_context *ctx, Lisp_Object object, | |||
| 2541 | ? aux_offset | 2575 | ? aux_offset |
| 2542 | : dump_blv (ctx, symbol->u.s.val.blv))); | 2576 | : dump_blv (ctx, symbol->u.s.val.blv))); |
| 2543 | break; | 2577 | break; |
| 2544 | case SYMBOL_FORWARDED: | ||
| 2545 | aux_offset = dump_recall_symbol_aux (ctx, make_lisp_symbol (symbol)); | ||
| 2546 | /* Symbols interned by a defvar are not copied objects. */ | ||
| 2547 | if (!aux_offset) | ||
| 2548 | dump_fwd (ctx, symbol->u.s.val.fwd); | ||
| 2549 | if (aux_offset && (aux_offset | ||
| 2550 | != emacs_offset (symbol->u.s.val.fwd.fwdptr))) | ||
| 2551 | emacs_abort (); | ||
| 2552 | break; | ||
| 2553 | default: | 2578 | default: |
| 2554 | break; | 2579 | break; |
| 2555 | } | 2580 | } |