diff options
| author | Philipp Stephani | 2019-04-19 18:38:19 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2019-04-19 18:41:15 +0200 |
| commit | 8aadf6e415b7801cb9fa4c5670b1750da207cf87 (patch) | |
| tree | be5b2ff82b5ffa0ef44684a76a9ad1676f13d3ed /src/emacs-module.c | |
| parent | bd93bcb078f29e9b5fa127d6cef0bdeeab5c2285 (diff) | |
| download | emacs-8aadf6e415b7801cb9fa4c5670b1750da207cf87.tar.gz emacs-8aadf6e415b7801cb9fa4c5670b1750da207cf87.zip | |
Refactoring: simplify definition of some internal variables.
In some cases, we never specbind internal objects, so they don't have
to be symbols. Rather than using DEFSYM/DEFVAR and then uninterning
the symbols, use plain static variables. Call staticpro for all of
them, to protect them from the garbage collector.
* src/eval.c (syms_of_eval): Use a static variable for
Qcatch_all_memory_full.
* src/emacs-module.c (syms_of_module): Use static variables for
Vmodule_refs_hash, Vmodule_runtimes, and Vmodule_environments.
Diffstat (limited to 'src/emacs-module.c')
| -rw-r--r-- | src/emacs-module.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 393a4354b88..ad32d3a91f1 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -349,6 +349,8 @@ module_get_environment (struct emacs_runtime *ert) | |||
| 349 | /* To make global refs (GC-protected global values) keep a hash that | 349 | /* To make global refs (GC-protected global values) keep a hash that |
| 350 | maps global Lisp objects to reference counts. */ | 350 | maps global Lisp objects to reference counts. */ |
| 351 | 351 | ||
| 352 | static Lisp_Object Vmodule_refs_hash; | ||
| 353 | |||
| 352 | static emacs_value | 354 | static emacs_value |
| 353 | module_make_global_ref (emacs_env *env, emacs_value ref) | 355 | module_make_global_ref (emacs_env *env, emacs_value ref) |
| 354 | { | 356 | { |
| @@ -760,6 +762,10 @@ module_signal_or_throw (struct emacs_env_private *env) | |||
| 760 | } | 762 | } |
| 761 | } | 763 | } |
| 762 | 764 | ||
| 765 | /* Live runtime and environment objects, for assertions. */ | ||
| 766 | static Lisp_Object Vmodule_runtimes; | ||
| 767 | static Lisp_Object Vmodule_environments; | ||
| 768 | |||
| 763 | DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0, | 769 | DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0, |
| 764 | doc: /* Load module FILE. */) | 770 | doc: /* Load module FILE. */) |
| 765 | (Lisp_Object file) | 771 | (Lisp_Object file) |
| @@ -1228,31 +1234,17 @@ module_abort (const char *format, ...) | |||
| 1228 | void | 1234 | void |
| 1229 | syms_of_module (void) | 1235 | syms_of_module (void) |
| 1230 | { | 1236 | { |
| 1231 | DEFSYM (Qmodule_refs_hash, "module-refs-hash"); | 1237 | staticpro (&Vmodule_refs_hash); |
| 1232 | DEFVAR_LISP ("module-refs-hash", Vmodule_refs_hash, | ||
| 1233 | doc: /* Module global reference table. */); | ||
| 1234 | |||
| 1235 | Vmodule_refs_hash | 1238 | Vmodule_refs_hash |
| 1236 | = make_hash_table (hashtest_eq, DEFAULT_HASH_SIZE, | 1239 | = make_hash_table (hashtest_eq, DEFAULT_HASH_SIZE, |
| 1237 | DEFAULT_REHASH_SIZE, DEFAULT_REHASH_THRESHOLD, | 1240 | DEFAULT_REHASH_SIZE, DEFAULT_REHASH_THRESHOLD, |
| 1238 | Qnil, false); | 1241 | Qnil, false); |
| 1239 | Funintern (Qmodule_refs_hash, Qnil); | ||
| 1240 | 1242 | ||
| 1241 | DEFSYM (Qmodule_runtimes, "module-runtimes"); | 1243 | staticpro (&Vmodule_runtimes); |
| 1242 | DEFVAR_LISP ("module-runtimes", Vmodule_runtimes, | ||
| 1243 | doc: /* List of active module runtimes. */); | ||
| 1244 | Vmodule_runtimes = Qnil; | 1244 | Vmodule_runtimes = Qnil; |
| 1245 | /* Unintern `module-runtimes' because it is only used | ||
| 1246 | internally. */ | ||
| 1247 | Funintern (Qmodule_runtimes, Qnil); | ||
| 1248 | 1245 | ||
| 1249 | DEFSYM (Qmodule_environments, "module-environments"); | 1246 | staticpro (&Vmodule_environments); |
| 1250 | DEFVAR_LISP ("module-environments", Vmodule_environments, | ||
| 1251 | doc: /* List of active module environments. */); | ||
| 1252 | Vmodule_environments = Qnil; | 1247 | Vmodule_environments = Qnil; |
| 1253 | /* Unintern `module-environments' because it is only used | ||
| 1254 | internally. */ | ||
| 1255 | Funintern (Qmodule_environments, Qnil); | ||
| 1256 | 1248 | ||
| 1257 | DEFSYM (Qmodule_load_failed, "module-load-failed"); | 1249 | DEFSYM (Qmodule_load_failed, "module-load-failed"); |
| 1258 | Fput (Qmodule_load_failed, Qerror_conditions, | 1250 | Fput (Qmodule_load_failed, Qerror_conditions, |
| @@ -1291,10 +1283,6 @@ syms_of_module (void) | |||
| 1291 | Fput (Qinvalid_arity, Qerror_message, | 1283 | Fput (Qinvalid_arity, Qerror_message, |
| 1292 | build_pure_c_string ("Invalid function arity")); | 1284 | build_pure_c_string ("Invalid function arity")); |
| 1293 | 1285 | ||
| 1294 | /* Unintern `module-refs-hash' because it is internal-only and Lisp | ||
| 1295 | code or modules should not access it. */ | ||
| 1296 | Funintern (Qmodule_refs_hash, Qnil); | ||
| 1297 | |||
| 1298 | DEFSYM (Qmodule_function_p, "module-function-p"); | 1286 | DEFSYM (Qmodule_function_p, "module-function-p"); |
| 1299 | 1287 | ||
| 1300 | defsubr (&Smodule_load); | 1288 | defsubr (&Smodule_load); |