aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Möllmann2024-06-29 18:01:23 +0200
committerGerd Möllmann2024-06-29 18:43:15 +0200
commit7f993bf780e34f4b718e43f1fd1f2bd1de4db311 (patch)
treed7eeb99ec2dffb936de82681cb804ff6209b097e
parent17514e28b51c291b0867e185d7174ab540826d31 (diff)
downloademacs-7f993bf780e34f4b718e43f1fd1f2bd1de4db311.tar.gz
emacs-7f993bf780e34f4b718e43f1fd1f2bd1de4db311.zip
Remove is_mps, replace with has_header
-rw-r--r--src/igc.c85
1 files changed, 33 insertions, 52 deletions
diff --git a/src/igc.c b/src/igc.c
index 506effd015d..dc927a2b4a6 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -259,11 +259,6 @@ enum
259 IGC_ALIGN_DFLT = IGC_ALIGN, 259 IGC_ALIGN_DFLT = IGC_ALIGN,
260}; 260};
261 261
262/* Using mps_arena_has_addr is expensive. so try to do something that is
263 "good enough". This can return true for malloc'd memory. */
264
265static mps_addr_t arena_min_addr, arena_max_addr;
266
267static bool 262static bool
268is_pure (const mps_addr_t addr) 263is_pure (const mps_addr_t addr)
269{ 264{
@@ -274,11 +269,35 @@ is_pure (const mps_addr_t addr)
274#endif 269#endif
275} 270}
276 271
272static enum pvec_type
273pseudo_vector_type (const struct Lisp_Vector *v)
274{
275 return PSEUDOVECTOR_TYPE (v);
276}
277
278static bool
279is_builtin_subr (enum igc_obj_type type, void *client)
280{
281 if (type == IGC_OBJ_VECTOR && pseudo_vector_type (client) == PVEC_SUBR)
282 {
283 Lisp_Object subr = make_lisp_ptr (client, Lisp_Vectorlike);
284 return !NATIVE_COMP_FUNCTIONP (subr);
285 }
286 return false;
287}
288
277static bool 289static bool
278is_mps (const mps_addr_t addr) 290has_header (void *client, bool is_vector)
279{ 291{
280 return addr >= arena_min_addr && addr < arena_max_addr 292 if (is_vector && is_builtin_subr (IGC_OBJ_VECTOR, client))
281 && !c_symbol_p (addr) && !is_pure (addr); 293 return false;
294 if (c_symbol_p (client))
295 return false;
296 if (client == &main_thread.s)
297 return false;
298 if (is_pure (client))
299 return false;
300 return true;
282} 301}
283 302
284static bool 303static bool
@@ -579,7 +598,7 @@ alloc_hash (void)
579void 598void
580igc_check_fwd (void *client) 599igc_check_fwd (void *client)
581{ 600{
582 if (is_mps (client)) 601 if (has_header (client))
583 { 602 {
584 struct igc_header *h = client_to_base (client); 603 struct igc_header *h = client_to_base (client);
585 igc_assert (h->obj_type != IGC_OBJ_FWD); 604 igc_assert (h->obj_type != IGC_OBJ_FWD);
@@ -756,12 +775,6 @@ deregister_thread (struct igc_thread_list *t)
756#pragma GCC diagnostic push 775#pragma GCC diagnostic push
757#pragma GCC diagnostic ignored "-Wunused-variable" 776#pragma GCC diagnostic ignored "-Wunused-variable"
758 777
759static enum pvec_type
760pseudo_vector_type (const struct Lisp_Vector *v)
761{
762 return PSEUDOVECTOR_TYPE (v);
763}
764
765static size_t 778static size_t
766vector_size (const struct Lisp_Vector *v) 779vector_size (const struct Lisp_Vector *v)
767{ 780{
@@ -3287,7 +3300,7 @@ igc_hash (Lisp_Object key)
3287 } 3300 }
3288 3301
3289 /* Objects in the The dump have igc_headers, too. */ 3302 /* Objects in the The dump have igc_headers, too. */
3290 if (is_mps (client)) 3303 if (has_header (client, tag == Lisp_Vectorlike))
3291 { 3304 {
3292 // The following assertion is very expensive. 3305 // The following assertion is very expensive.
3293 // igc_assert (mps_arena_has_addr (global_igc->arena, client)); 3306 // igc_assert (mps_arena_has_addr (global_igc->arena, client));
@@ -3829,35 +3842,11 @@ DEFUN ("igc--roots", Figc__roots, Sigc__roots, 0, 0, 0, doc : /* */)
3829} 3842}
3830 3843
3831static void 3844static void
3832arena_extended (mps_arena_t arena, void *base, size_t size)
3833{
3834 if (arena_min_addr == NULL || base < arena_min_addr)
3835 arena_min_addr = base;
3836 mps_addr_t end = (char *) base + size;
3837 if (arena_max_addr == NULL || end > arena_max_addr)
3838 arena_max_addr = end;
3839}
3840
3841static void
3842arena_contracted (mps_arena_t arena, void *base, size_t size)
3843{
3844 /* Can MPS free something that is in the middle? */
3845 mps_addr_t end = (char *) base + size;
3846 if (end == arena_max_addr)
3847 arena_max_addr = base;
3848 if (base == arena_min_addr)
3849 arena_min_addr = end;
3850}
3851
3852static void
3853make_arena (struct igc *gc) 3845make_arena (struct igc *gc)
3854{ 3846{
3855 mps_res_t res; 3847 mps_res_t res;
3856 MPS_ARGS_BEGIN (args) 3848 MPS_ARGS_BEGIN (args)
3857 { 3849 {
3858 MPS_ARGS_ADD (args, MPS_KEY_ARENA_EXTENDED, (mps_fun_t) &arena_extended);
3859 MPS_ARGS_ADD (args, MPS_KEY_ARENA_CONTRACTED,
3860 (mps_fun_t) &arena_contracted);
3861 res = mps_arena_create_k (&gc->arena, mps_arena_class_vm (), args); 3850 res = mps_arena_create_k (&gc->arena, mps_arena_class_vm (), args);
3862 } 3851 }
3863 MPS_ARGS_END (args); 3852 MPS_ARGS_END (args);
@@ -4001,17 +3990,6 @@ igc_header_size (void)
4001 return sizeof (struct igc_header); 3990 return sizeof (struct igc_header);
4002} 3991}
4003 3992
4004static bool
4005is_builtin_subr (enum igc_obj_type type, void *client)
4006{
4007 if (type == IGC_OBJ_VECTOR && pseudo_vector_type (client) == PVEC_SUBR)
4008 {
4009 Lisp_Object subr = make_lisp_ptr (client, Lisp_Vectorlike);
4010 return !NATIVE_COMP_FUNCTIONP (subr);
4011 }
4012 return false;
4013}
4014
4015static enum igc_obj_type 3993static enum igc_obj_type
4016builtin_obj_type_and_hash (size_t *hash, enum igc_obj_type type, void *client) 3994builtin_obj_type_and_hash (size_t *hash, enum igc_obj_type type, void *client)
4017{ 3995{
@@ -4110,7 +4088,10 @@ igc_dump_finish_obj (void *client, enum igc_obj_type type,
4110 } 4088 }
4111 4089
4112 struct igc_header *out = (struct igc_header *) base; 4090 struct igc_header *out = (struct igc_header *) base;
4113 if (is_mps (client) && !is_in_dump) 4091
4092 /* If the client object to be dumped has a header, copy that. */
4093 if (has_header (client, type == IGC_OBJ_VECTOR)
4094 && !is_in_dump)
4114 { 4095 {
4115 struct igc_header *h = client_to_base (client); 4096 struct igc_header *h = client_to_base (client);
4116 if (h->obj_type == IGC_OBJ_VECTOR_WEAK) 4097 if (h->obj_type == IGC_OBJ_VECTOR_WEAK)