aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorMattias EngdegÄrd2024-01-19 15:17:52 +0100
committerMattias EngdegÄrd2024-01-21 11:21:51 +0100
commitfec87a4b36a67688932e7bb7e1720bd2c4363a61 (patch)
tree8549ad5b17f75ba86a77e5fd8dea8a77bb3133af /src/comp.c
parent0a07603ae8db41f69e83b1bfec6e28a92f737852 (diff)
downloademacs-fec87a4b36a67688932e7bb7e1720bd2c4363a61.tar.gz
emacs-fec87a4b36a67688932e7bb7e1720bd2c4363a61.zip
Add C macro for hash table iteration
This removes some boilerplate code and further reduces dependencies on hash table implementation internals. * src/lisp.h (DOHASH): New. * src/comp.c (compile_function, Fcomp__compile_ctxt_to_file): * src/composite.c (composition_gstring_cache_clear_font): * src/emacs-module.c (module_global_reference_p): * src/fns.c (Fmaphash): * src/json.c (lisp_to_json_nonscalar_1): * src/minibuf.c (Ftest_completion): * src/print.c (print): Use it instead of a hand-written loop.
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/src/comp.c b/src/comp.c
index 3f9e738d9a7..25c4cb2f22c 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -4330,11 +4330,10 @@ compile_function (Lisp_Object func)
4330 declare_block (Qentry); 4330 declare_block (Qentry);
4331 Lisp_Object blocks = CALL1I (comp-func-blocks, func); 4331 Lisp_Object blocks = CALL1I (comp-func-blocks, func);
4332 struct Lisp_Hash_Table *ht = XHASH_TABLE (blocks); 4332 struct Lisp_Hash_Table *ht = XHASH_TABLE (blocks);
4333 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (ht); i++) 4333 DOHASH (ht, i)
4334 { 4334 {
4335 Lisp_Object block_name = HASH_KEY (ht, i); 4335 Lisp_Object block_name = HASH_KEY (ht, i);
4336 if (!EQ (block_name, Qentry) 4336 if (!EQ (block_name, Qentry))
4337 && !hash_unused_entry_key_p (block_name))
4338 declare_block (block_name); 4337 declare_block (block_name);
4339 } 4338 }
4340 4339
@@ -4344,24 +4343,21 @@ compile_function (Lisp_Object func)
4344 gcc_jit_lvalue_as_rvalue (comp.func_relocs)); 4343 gcc_jit_lvalue_as_rvalue (comp.func_relocs));
4345 4344
4346 4345
4347 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (ht); i++) 4346 DOHASH (ht, i)
4348 { 4347 {
4349 Lisp_Object block_name = HASH_KEY (ht, i); 4348 Lisp_Object block_name = HASH_KEY (ht, i);
4350 if (!hash_unused_entry_key_p (block_name)) 4349 Lisp_Object block = HASH_VALUE (ht, i);
4350 Lisp_Object insns = CALL1I (comp-block-insns, block);
4351 if (NILP (block) || NILP (insns))
4352 xsignal1 (Qnative_ice,
4353 build_string ("basic block is missing or empty"));
4354
4355 comp.block = retrive_block (block_name);
4356 while (CONSP (insns))
4351 { 4357 {
4352 Lisp_Object block = HASH_VALUE (ht, i); 4358 Lisp_Object insn = XCAR (insns);
4353 Lisp_Object insns = CALL1I (comp-block-insns, block); 4359 emit_limple_insn (insn);
4354 if (NILP (block) || NILP (insns)) 4360 insns = XCDR (insns);
4355 xsignal1 (Qnative_ice,
4356 build_string ("basic block is missing or empty"));
4357
4358 comp.block = retrive_block (block_name);
4359 while (CONSP (insns))
4360 {
4361 Lisp_Object insn = XCAR (insns);
4362 emit_limple_insn (insn);
4363 insns = XCDR (insns);
4364 }
4365 } 4361 }
4366 } 4362 }
4367 const char *err = gcc_jit_context_get_first_error (comp.ctxt); 4363 const char *err = gcc_jit_context_get_first_error (comp.ctxt);
@@ -4965,14 +4961,10 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file,
4965 4961
4966 struct Lisp_Hash_Table *func_h = 4962 struct Lisp_Hash_Table *func_h =
4967 XHASH_TABLE (CALL1I (comp-ctxt-funcs-h, Vcomp_ctxt)); 4963 XHASH_TABLE (CALL1I (comp-ctxt-funcs-h, Vcomp_ctxt));
4968 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (func_h); i++) 4964 DOHASH (func_h, i) declare_function (HASH_VALUE (func_h, i));
4969 if (!hash_unused_entry_key_p (HASH_KEY (func_h, i)))
4970 declare_function (HASH_VALUE (func_h, i));
4971 /* Compile all functions. Can't be done before because the 4965 /* Compile all functions. Can't be done before because the
4972 relocation structs has to be already defined. */ 4966 relocation structs has to be already defined. */
4973 for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (func_h); i++) 4967 DOHASH (func_h, i) compile_function (HASH_VALUE (func_h, i));
4974 if (!hash_unused_entry_key_p (HASH_KEY (func_h, i)))
4975 compile_function (HASH_VALUE (func_h, i));
4976 4968
4977 /* Work around bug#46495 (GCC PR99126). */ 4969 /* Work around bug#46495 (GCC PR99126). */
4978#if defined (WIDE_EMACS_INT) \ 4970#if defined (WIDE_EMACS_INT) \