aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2020-03-28 20:56:47 +0000
committerAndrea Corallo2020-03-29 12:30:33 +0100
commitd5f6dc131b63d6bde096c03927c05a490c707c41 (patch)
tree59f84f98aab7fb446fb79ceca31ffca1b70b3574 /src
parent9d8ce520f03217e5aaf08b3e252a1bb82c3fc641 (diff)
downloademacs-d5f6dc131b63d6bde096c03927c05a490c707c41.tar.gz
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')
-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 {
174 gcc_jit_function *check_type; 174 gcc_jit_function *check_type;
175 gcc_jit_function *check_impure; 175 gcc_jit_function *check_impure;
176 Lisp_Object func_blocks_h; /* blk_name -> gcc_block. */ 176 Lisp_Object func_blocks_h; /* blk_name -> gcc_block. */
177 Lisp_Object exported_funcs_h; /* subr_name -> gcc_jit_function *. */ 177 Lisp_Object exported_funcs_h; /* c-func-name -> gcc_jit_function *. */
178 Lisp_Object imported_funcs_h; /* subr_name -> gcc_jit_field *reloc_field. */ 178 Lisp_Object imported_funcs_h; /* subr_name -> gcc_jit_field *reloc_field. */
179 Lisp_Object emitter_dispatcher; 179 Lisp_Object emitter_dispatcher;
180 /* Synthesized struct holding data relocs. */ 180 /* Synthesized struct holding data relocs. */
@@ -518,9 +518,18 @@ static gcc_jit_rvalue *
518emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, ptrdiff_t nargs, 518emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, ptrdiff_t nargs,
519 gcc_jit_rvalue **args, bool direct) 519 gcc_jit_rvalue **args, bool direct)
520{ 520{
521 Lisp_Object func = 521 Lisp_Object func;
522 Fgethash (subr_sym, direct ? comp.exported_funcs_h: comp.imported_funcs_h, 522 if (direct)
523 Qnil); 523 {
524 Lisp_Object c_name =
525 Fgethash (subr_sym,
526 CALL1I (comp-ctxt-sym-to-c-name-h, Vcomp_ctxt),
527 Qnil);
528 func = Fgethash (c_name, comp.exported_funcs_h, Qnil);
529 }
530 else
531 func = Fgethash (subr_sym, comp.imported_funcs_h, Qnil);
532
524 if (NILP (func)) 533 if (NILP (func))
525 xsignal2 (Qnative_ice, 534 xsignal2 (Qnative_ice,
526 build_string ("missing function declaration"), 535 build_string ("missing function declaration"),
@@ -2926,7 +2935,7 @@ declare_function (Lisp_Object func)
2926 c_name, 2, param, 0); 2935 c_name, 2, param, 0);
2927 } 2936 }
2928 2937
2929 Fputhash (CALL1I (comp-func-name, func), 2938 Fputhash (CALL1I (comp-func-c-name, func),
2930 make_mint_ptr (gcc_func), 2939 make_mint_ptr (gcc_func),
2931 comp.exported_funcs_h); 2940 comp.exported_funcs_h);
2932 2941
@@ -2939,7 +2948,7 @@ compile_function (Lisp_Object func)
2939 USE_SAFE_ALLOCA; 2948 USE_SAFE_ALLOCA;
2940 EMACS_INT frame_size = XFIXNUM (CALL1I (comp-func-frame-size, func)); 2949 EMACS_INT frame_size = XFIXNUM (CALL1I (comp-func-frame-size, func));
2941 2950
2942 comp.func = xmint_pointer (Fgethash (CALL1I (comp-func-name, func), 2951 comp.func = xmint_pointer (Fgethash (CALL1I (comp-func-c-name, func),
2943 comp.exported_funcs_h, Qnil)); 2952 comp.exported_funcs_h, Qnil));
2944 2953
2945 comp.func_has_non_local = !NILP (CALL1I (comp-func-has-non-local, func)); 2954 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,
3179 sizeof (void *), 3188 sizeof (void *),
3180 false); 3189 false);
3181 3190
3182 comp.exported_funcs_h = CALLN (Fmake_hash_table); 3191 comp.exported_funcs_h = CALLN (Fmake_hash_table, QCtest, Qequal);
3183 /* 3192 /*
3184 Always reinitialize this cause old function definitions are garbage 3193 Always reinitialize this cause old function definitions are garbage
3185 collected by libgccjit when the ctxt is released. 3194 collected by libgccjit when the ctxt is released.