[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/igc b7e5aeede34 1/2: Use ptr_vec for face and imag4 caches
From: |
Gerd Moellmann |
Subject: |
scratch/igc b7e5aeede34 1/2: Use ptr_vec for face and imag4 caches |
Date: |
Sat, 18 May 2024 00:01:38 -0400 (EDT) |
branch: scratch/igc
commit b7e5aeede34182622ac5417a84790674809c6a64
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>
Use ptr_vec for face and imag4 caches
---
admin/IGC-TODO | 16 ++++++++++++++++
src/igc.c | 35 ++++-------------------------------
src/image.c | 9 +++++++++
src/xfaces.c | 11 ++++++++---
4 files changed, 37 insertions(+), 34 deletions(-)
diff --git a/admin/IGC-TODO b/admin/IGC-TODO
index 6d4c9372d49..fed2552da20 100644
--- a/admin/IGC-TODO
+++ b/admin/IGC-TODO
@@ -11,6 +11,22 @@ Todo list for scratch/igc
- Maybe implement weak-ptr for the old GC.
+- Make native compilation work on macOS. (Might be fixed with Helmut's
+ exact root approach, but can't check because Homebrew libgccjit 14.1
+ makes problems when configuring (libgcc_s.dylib not found)).
+Todo list for scratch/igc
+
+- Complete the code to mirror the object graph in a loaded dump in MPS.
+
+- Write the code that replaces references to the loaded dump with
+ references to the mirrored graph in all roots.
+
+- Implement weak hash tables.
+
+- Write the code to handle marker lists, undo list etc.
+
+- Maybe implement weak-ptr for the old GC.
+
- Make native compilation work on macOS. (Might be fixed with Helmut's
exact root approach, but can't check because Homebrew libgccjit 14.1
makes problems when configuring (libgcc_s.dylib not found)).
diff --git a/src/igc.c b/src/igc.c
index 9386d55a851..5e7a1fc9963 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -1073,17 +1073,8 @@ fix_image_cache (mps_ss_t ss, struct image_cache *c)
MPS_SCAN_BEGIN (ss)
{
#ifdef HAVE_WINDOW_SYSTEM
- /* FIXME: the malloc'd buckets and images are not included in
- the exclusive access granted to the image cache by MPS. */
- if (c->images)
- for (ptrdiff_t i = 0; i < c->used; ++i)
- if (c->images[i])
- IGC_FIX12_RAW (ss, &c->images[i]);
-
- if (c->buckets)
- for (ptrdiff_t i = 0; i < IMAGE_CACHE_BUCKETS_SIZE; ++i)
- if (c->buckets[i])
- IGC_FIX12_RAW (ss, &c->buckets[i]);
+ IGC_FIX12_RAW (ss, &c->images);
+ IGC_FIX12_RAW (ss, &c->buckets);
#endif
}
MPS_SCAN_END (ss);
@@ -1108,32 +1099,14 @@ fix_face (mps_ss_t ss, struct face *f)
return MPS_RES_OK;
}
-/* FIXME: Bot image_cache and face_cache are hash tables containing
- malloc'd vectors. Tracing these here and in fix_image_cache is
- strictly speaking not safe 100% safe, because MPS only guarantess
- exclusive access to the face_cache itself, not its malloc'd vectors.
-
- Introduce a new IGC_OBJ_PTR_VECTOR. That object is an array of
- pointers that are guaranteed to point to MPS objects if non-null. Use
- these objects for the four vectors in face_cache and image_cache. */
-
static mps_res_t
fix_face_cache (mps_ss_t ss, struct face_cache *c)
{
MPS_SCAN_BEGIN (ss)
{
IGC_FIX12_RAW (ss, &c->f);
- if (c->faces_by_id)
- for (int i = 0; i < c->used; ++i)
- {
- igc_assert (c->faces_by_id[i] != NULL);
- IGC_FIX12_RAW (ss, &c->faces_by_id[i]);
- }
-
- if (c->buckets)
- for (int i = 0; i < FACE_CACHE_BUCKETS_SIZE; ++i)
- if (c->buckets[i])
- IGC_FIX12_RAW (ss, &c->buckets[i]);
+ IGC_FIX12_RAW (ss, &c->faces_by_id);
+ IGC_FIX12_RAW (ss, &c->buckets);
}
MPS_SCAN_END (ss);
return MPS_RES_OK;
diff --git a/src/image.c b/src/image.c
index 4c570e0c776..44a94cc4a4e 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2121,8 +2121,13 @@ make_image_cache (void)
c->size = 50;
c->used = c->refcount = 0;
+#ifdef HAVE_MPS
+ c->images = igc_make_ptr_vec (c->size);
+ c->buckets = igc_make_ptr_vec (IMAGE_CACHE_BUCKETS_SIZE);
+#else
c->images = xmalloc (c->size * sizeof *c->images);
c->buckets = xzalloc (IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets);
+#endif
return c;
}
@@ -2239,9 +2244,13 @@ free_image_cache (struct frame *f)
for (i = 0; i < c->used; ++i)
free_image (f, c->images[i]);
+#ifndef HAVE_MPS
xfree (c->images);
+#endif
c->images = NULL;
+#ifndef HAVE_MPS
xfree (c->buckets);
+#endif
c->buckets = NULL;
#ifndef HAVE_MPS
xfree (c);
diff --git a/src/xfaces.c b/src/xfaces.c
index 183012b8fe7..e7640021061 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4738,11 +4738,16 @@ make_face_cache (struct frame *f)
c = xmalloc (sizeof *c);
#endif
- c->buckets = xzalloc (FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets);
+ c->f = f;
c->size = 50;
c->used = 0;
+#ifdef HAVE_MPS
+ c->buckets = igc_make_ptr_vec (FACE_CACHE_BUCKETS_SIZE);
+ c->faces_by_id = igc_make_ptr_vec (c->size);
+#else
+ c->buckets = xzalloc (FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets);
c->faces_by_id = xzalloc (c->size * sizeof *c->faces_by_id);
- c->f = f;
+#endif
c->menu_face_changed_p = menu_face_changed_default;
return c;
}
@@ -4849,13 +4854,13 @@ free_face_cache (struct face_cache *c)
if (c)
{
free_realized_faces (c);
+#ifndef HAVE_MPS
struct face **p = c->buckets;
c->buckets = NULL;
xfree (p);
p = c->faces_by_id;
c->faces_by_id = NULL;
xfree (p);
-#ifndef HAVE_MPS
xfree (c);
#endif
}