summaryrefslogtreecommitdiff
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2020-03-28 20:56:47 +0000
committerAndrea Corallo <akrl@sdf.org>2020-03-29 12:30:33 +0100
commitd5f6dc131b63d6bde096c03927c05a490c707c41 (patch)
tree59f84f98aab7fb446fb79ceca31ffca1b70b3574 /src/comp.c
parent9d8ce520f03217e5aaf08b3e252a1bb82c3fc641 (diff)
downloademacs-d5f6dc131b63d6bde096c03927c05a490c707c41.tar.gz
emacs-d5f6dc131b63d6bde096c03927c05a490c707c41.tar.bz2
emacs-d5f6dc131b63d6bde096c03927c05a490c707c41.zip
Prevent collisions in C namespace and function shadowing
This rework make functions being indexed by their unique C symbol name preventing multiple lisp function with the same name colliding.
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/comp.c b/src/comp.c
index 563f6250730..2aa0c472217 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -174,7 +174,7 @@ typedef struct {
gcc_jit_function *check_type;
gcc_jit_function *check_impure;
Lisp_Object func_blocks_h; /* blk_name -> gcc_block. */
- Lisp_Object exported_funcs_h; /* subr_name -> gcc_jit_function *. */
+ Lisp_Object exported_funcs_h; /* c-func-name -> gcc_jit_function *. */
Lisp_Object imported_funcs_h; /* subr_name -> gcc_jit_field *reloc_field. */
Lisp_Object emitter_dispatcher;
/* Synthesized struct holding data relocs. */
@@ -518,9 +518,18 @@ static gcc_jit_rvalue *
emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, ptrdiff_t nargs,
gcc_jit_rvalue **args, bool direct)
{
- Lisp_Object func =
- Fgethash (subr_sym, direct ? comp.exported_funcs_h: comp.imported_funcs_h,
- Qnil);
+ Lisp_Object func;
+ if (direct)
+ {
+ Lisp_Object c_name =
+ Fgethash (subr_sym,
+ CALL1I (comp-ctxt-sym-to-c-name-h, Vcomp_ctxt),
+ Qnil);
+ func = Fgethash (c_name, comp.exported_funcs_h, Qnil);
+ }
+ else
+ func = Fgethash (subr_sym, comp.imported_funcs_h, Qnil);
+
if (NILP (func))
xsignal2 (Qnative_ice,
build_string ("missing function declaration"),
@@ -2926,7 +2935,7 @@ declare_function (Lisp_Object func)
c_name, 2, param, 0);
}
- Fputhash (CALL1I (comp-func-name, func),
+ Fputhash (CALL1I (comp-func-c-name, func),
make_mint_ptr (gcc_func),
comp.exported_funcs_h);
@@ -2939,7 +2948,7 @@ compile_function (Lisp_Object func)
USE_SAFE_ALLOCA;
EMACS_INT frame_size = XFIXNUM (CALL1I (comp-func-frame-size, func));
- comp.func = xmint_pointer (Fgethash (CALL1I (comp-func-name, func),
+ comp.func = xmint_pointer (Fgethash (CALL1I (comp-func-c-name, func),
comp.exported_funcs_h, Qnil));
comp.func_has_non_local = !NILP (CALL1I (comp-func-has-non-local, func));
@@ -3179,7 +3188,7 @@ DEFUN ("comp--init-ctxt", Fcomp__init_ctxt, Scomp__init_ctxt,
sizeof (void *),
false);
- comp.exported_funcs_h = CALLN (Fmake_hash_table);
+ comp.exported_funcs_h = CALLN (Fmake_hash_table, QCtest, Qequal);
/*
Always reinitialize this cause old function definitions are garbage
collected by libgccjit when the ctxt is released.