diff options
| author | Mattias EngdegÄrd | 2024-01-25 18:56:03 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-01-27 12:37:53 +0100 |
| commit | da726c6de201cdb9123bd99e22206dbed5fdc50f (patch) | |
| tree | 7211aebebf8b41c6aa2206882ae2ed271eba479b /src/comp.c | |
| parent | 9b3f43fa08b2672a5ef33b872b2c6d1b0e881b88 (diff) | |
| download | emacs-da726c6de201cdb9123bd99e22206dbed5fdc50f.tar.gz emacs-da726c6de201cdb9123bd99e22206dbed5fdc50f.zip | |
Add DOHASH_SAFE, make DOHASH faster (bug#68690)
Revert DOHASH to the fast (field-caching) implementation but with
an assertion to detect misuses. Add DOHASH_SAFE for use in
code that must tolerate arbitrary mutation of the table being
iterated through.
* src/lisp.h (DOHASH): Go back to fast design that only allows
restricted mutation, but with a checking assertion.
(DOHASH_SAFE): New macro that tolerates arbitrary mutation while being
much simpler (and acceptably fast).
* src/fns.c (Fmaphash):
* src/comp.c (compile_function, Fcomp__compile_ctxt_to_file):
Use DOHASH_SAFE.
Diffstat (limited to 'src/comp.c')
| -rw-r--r-- | src/comp.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/comp.c b/src/comp.c index 5f28cf046b5..853757f6162 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -4330,9 +4330,12 @@ 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 | DOHASH (ht, block_name, block) | 4333 | DOHASH_SAFE (ht, i) |
| 4334 | if (!EQ (block_name, Qentry)) | 4334 | { |
| 4335 | declare_block (block_name); | 4335 | Lisp_Object block_name = HASH_KEY (ht, i); |
| 4336 | if (!EQ (block_name, Qentry)) | ||
| 4337 | declare_block (block_name); | ||
| 4338 | } | ||
| 4336 | 4339 | ||
| 4337 | gcc_jit_block_add_assignment (retrive_block (Qentry), | 4340 | gcc_jit_block_add_assignment (retrive_block (Qentry), |
| 4338 | NULL, | 4341 | NULL, |
| @@ -4340,8 +4343,10 @@ compile_function (Lisp_Object func) | |||
| 4340 | gcc_jit_lvalue_as_rvalue (comp.func_relocs)); | 4343 | gcc_jit_lvalue_as_rvalue (comp.func_relocs)); |
| 4341 | 4344 | ||
| 4342 | 4345 | ||
| 4343 | DOHASH (ht, block_name, block) | 4346 | DOHASH_SAFE (ht, i) |
| 4344 | { | 4347 | { |
| 4348 | Lisp_Object block_name = HASH_KEY (ht, i); | ||
| 4349 | Lisp_Object block = HASH_VALUE (ht, i); | ||
| 4345 | Lisp_Object insns = CALL1I (comp-block-insns, block); | 4350 | Lisp_Object insns = CALL1I (comp-block-insns, block); |
| 4346 | if (NILP (block) || NILP (insns)) | 4351 | if (NILP (block) || NILP (insns)) |
| 4347 | xsignal1 (Qnative_ice, | 4352 | xsignal1 (Qnative_ice, |
| @@ -4956,12 +4961,12 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file, | |||
| 4956 | 4961 | ||
| 4957 | struct Lisp_Hash_Table *func_h = | 4962 | struct Lisp_Hash_Table *func_h = |
| 4958 | XHASH_TABLE (CALL1I (comp-ctxt-funcs-h, Vcomp_ctxt)); | 4963 | XHASH_TABLE (CALL1I (comp-ctxt-funcs-h, Vcomp_ctxt)); |
| 4959 | DOHASH (func_h, k, v) | 4964 | DOHASH_SAFE (func_h, i) |
| 4960 | declare_function (v); | 4965 | declare_function (HASH_VALUE (func_h, i)); |
| 4961 | /* Compile all functions. Can't be done before because the | 4966 | /* Compile all functions. Can't be done before because the |
| 4962 | relocation structs has to be already defined. */ | 4967 | relocation structs has to be already defined. */ |
| 4963 | DOHASH (func_h, k, v) | 4968 | DOHASH_SAFE (func_h, i) |
| 4964 | compile_function (v); | 4969 | compile_function (HASH_VALUE (func_h, i)); |
| 4965 | 4970 | ||
| 4966 | /* Work around bug#46495 (GCC PR99126). */ | 4971 | /* Work around bug#46495 (GCC PR99126). */ |
| 4967 | #if defined (WIDE_EMACS_INT) \ | 4972 | #if defined (WIDE_EMACS_INT) \ |