Commit 8aadf6e4 authored by Philipp Stephani's avatar Philipp Stephani
Browse files

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

* src/emacs-module.c (syms_of_module): Use static variables for
Vmodule_refs_hash, Vmodule_runtimes, and Vmodule_environments.
parent bd93bcb0
Pipeline #1354 failed with stage
in 60 minutes and 1 second
......@@ -349,6 +349,8 @@ module_get_environment (struct emacs_runtime *ert)
/* To make global refs (GC-protected global values) keep a hash that
maps global Lisp objects to reference counts. */
static Lisp_Object Vmodule_refs_hash;
static emacs_value
module_make_global_ref (emacs_env *env, emacs_value ref)
......@@ -760,6 +762,10 @@ module_signal_or_throw (struct emacs_env_private *env)
/* Live runtime and environment objects, for assertions. */
static Lisp_Object Vmodule_runtimes;
static Lisp_Object Vmodule_environments;
DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
doc: /* Load module FILE. */)
(Lisp_Object file)
......@@ -1228,31 +1234,17 @@ module_abort (const char *format, ...)
syms_of_module (void)
DEFSYM (Qmodule_refs_hash, "module-refs-hash");
DEFVAR_LISP ("module-refs-hash", Vmodule_refs_hash,
doc: /* Module global reference table. */);
staticpro (&Vmodule_refs_hash);
= make_hash_table (hashtest_eq, DEFAULT_HASH_SIZE,
Qnil, false);
Funintern (Qmodule_refs_hash, Qnil);
DEFSYM (Qmodule_runtimes, "module-runtimes");
DEFVAR_LISP ("module-runtimes", Vmodule_runtimes,
doc: /* List of active module runtimes. */);
staticpro (&Vmodule_runtimes);
Vmodule_runtimes = Qnil;
/* Unintern `module-runtimes' because it is only used
internally. */
Funintern (Qmodule_runtimes, Qnil);
DEFSYM (Qmodule_environments, "module-environments");
DEFVAR_LISP ("module-environments", Vmodule_environments,
doc: /* List of active module environments. */);
staticpro (&Vmodule_environments);
Vmodule_environments = Qnil;
/* Unintern `module-environments' because it is only used
internally. */
Funintern (Qmodule_environments, Qnil);
DEFSYM (Qmodule_load_failed, "module-load-failed");
Fput (Qmodule_load_failed, Qerror_conditions,
......@@ -1291,10 +1283,6 @@ syms_of_module (void)
Fput (Qinvalid_arity, Qerror_message,
build_pure_c_string ("Invalid function arity"));
/* Unintern `module-refs-hash' because it is internal-only and Lisp
code or modules should not access it. */
Funintern (Qmodule_refs_hash, Qnil);
DEFSYM (Qmodule_function_p, "module-function-p");
defsubr (&Smodule_load);
......@@ -1429,6 +1429,8 @@ internal_condition_case_n (Lisp_Object (*bfun) (ptrdiff_t, Lisp_Object *),
static Lisp_Object Qcatch_all_memory_full;
/* Like a combination of internal_condition_case_1 and internal_catch.
Catches all signals and throws. Never exits nonlocally; returns
Qcatch_all_memory_full if no handler could be allocated. */
......@@ -4188,8 +4190,12 @@ alist of active lexical bindings. */);
staticpro (&Vsignaling_function);
Vsignaling_function = Qnil;
DEFSYM (Qcatch_all_memory_full, "catch-all-memory-full");
Funintern (Qcatch_all_memory_full, Qnil);
staticpro (&Qcatch_all_memory_full);
/* Make sure Qcatch_all_memory_full is a unique object. We could
also use something like Fcons (Qnil, Qnil), but json.c treats any
cons cell as error data, so use an uninterned symbol instead. */
= Fmake_symbol (build_pure_c_string ("catch-all-memory-full"));
defsubr (&Sor);
defsubr (&Sand);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment