1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-06 22:31:13 -07:00

Avoid remote references in fix_frame by making glyph_pools roots

* src/igc.h (igc_alloc_glyph_pool): New prototype.
* src/igc.c (igc_alloc_glyph_pool, scan_glyph_pool): New.
(fix_frame): Don't trace the glyph_pools.
(fix_glyph_matrix): Should only be used for matrices with their own
glyphs.
* src/dispnew.c (new_glyph_matrix, free_glyph_matrix): Only create roots
for matrices without pool.
(new_glyph_pool, free_glyph_pool): Create and destroy roots for glyph
pools.
This commit is contained in:
Helmut Eller 2026-04-03 17:15:57 +02:00
parent 786dfd08d9
commit bf078ca797
3 changed files with 34 additions and 2 deletions

View file

@ -257,7 +257,8 @@ static struct glyph_matrix *
new_glyph_matrix (struct glyph_pool *pool)
{
#ifdef HAVE_MPS
struct glyph_matrix *result = igc_alloc_glyph_matrix ();
struct glyph_matrix *result
= pool ? xzalloc (sizeof *result) : igc_alloc_glyph_matrix ();
#else
struct glyph_matrix *result = xzalloc (sizeof *result);
#endif
@ -306,7 +307,10 @@ free_glyph_matrix (struct glyph_matrix *matrix)
/* Free row structures and the matrix itself. */
xfree (matrix->rows);
#ifdef HAVE_MPS
igc_xfree (matrix);
if (matrix->pool == NULL)
igc_xfree (matrix);
else
xfree (matrix);
#else
xfree (matrix);
#endif
@ -1357,7 +1361,11 @@ row_equal_p (struct glyph_row *a, struct glyph_row *b, bool mouse_face_p)
static struct glyph_pool * ATTRIBUTE_MALLOC
new_glyph_pool (void)
{
#ifdef HAVE_MPS
struct glyph_pool *result = igc_alloc_glyph_pool ();
#else
struct glyph_pool *result = xzalloc (sizeof *result);
#endif
#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
/* For memory leak and double deletion checking. */
@ -1386,7 +1394,11 @@ free_glyph_pool (struct glyph_pool *pool)
eassert (glyph_pool_count >= 0);
#endif
xfree (pool->glyphs);
#ifdef HAVE_MPS
igc_xfree (pool);
#else
xfree (pool);
#endif
}
}

View file

@ -2832,6 +2832,7 @@ fix_glyph_array (mps_ss_t ss, size_t len, struct glyph array[len])
static mps_res_t
fix_glyph_matrix (mps_ss_t ss, struct glyph_matrix *matrix)
{
igc_assert (matrix->pool == NULL);
MPS_SCAN_BEGIN (ss)
{
struct glyph_row *row = matrix->rows;
@ -2898,10 +2899,12 @@ fix_frame (mps_ss_t ss, struct frame *f)
IGC_FIX12_OBJ (ss, &f->conversion.field);
#endif
#if 0
if (f->current_pool)
IGC_FIX_CALL (ss, fix_glyph_pool (ss, f->current_pool));
if (f->desired_pool)
IGC_FIX_CALL (ss, fix_glyph_pool (ss, f->desired_pool));
#endif
}
MPS_SCAN_END (ss);
return MPS_RES_OK;
@ -4320,6 +4323,22 @@ igc_alloc_glyph_matrix (void)
return m;
}
static mps_res_t
scan_glyph_pool (mps_ss_t ss, void *start, void *end, void *closure)
{
struct glyph_pool *p = start;
return fix_glyph_pool (ss, p);
}
struct glyph_pool *
igc_alloc_glyph_pool (void)
{
struct glyph_pool *p = xzalloc (sizeof *p);
root_create_exact (global_igc, p, p + 1, scan_glyph_pool,
"glyph_pool");
return p;
}
static void
finalize_font (struct font *font)
{

View file

@ -82,6 +82,7 @@ Lisp_Object *igc_xnrealloc_lisp_objs_exact (ptrdiff_t nitems_old,
struct kboard *igc_alloc_kboard (void);
struct hash_table_user_test *igc_alloc_hash_table_user_test (void);
struct glyph_matrix *igc_alloc_glyph_matrix (void);
struct glyph_pool *igc_alloc_glyph_pool (void);
struct Lisp_Vector *igc_alloc_pseudovector (size_t nwords_mem,
size_t nwords_lisp,